Skip to content

Commit

Permalink
Add samples for localDateTimeAssertions expect values (robstoll#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhushikesh committed Oct 10, 2021
1 parent 68e79ff commit de10e1a
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import java.time.LocalDateTime
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateTimeExpectationSamples.yearFeature
*
* @since 0.9.0
*/
val Expect<LocalDateTime>.year: Expect<Int>
Expand All @@ -42,6 +44,8 @@ fun Expect<LocalDateTime>.year(assertionCreator: Expect<Int>.() -> Unit): Expect
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateTimeExpectationSamples.monthFeature
*
* @since 0.9.0
*/
val Expect<LocalDateTime>.month: Expect<Int>
Expand All @@ -67,6 +71,8 @@ fun Expect<LocalDateTime>.month(assertionCreator: Expect<Int>.() -> Unit): Expec
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateTimeExpectationSamples.dayOfWeekFeature
*
* @since 0.9.0
*/
val Expect<LocalDateTime>.dayOfWeek: Expect<DayOfWeek>
Expand All @@ -92,6 +98,8 @@ fun Expect<LocalDateTime>.dayOfWeek(assertionCreator: Expect<DayOfWeek>.() -> Un
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateTimeExpectationSamples.dayFeature
*
* @since 0.9.0
*/
val Expect<LocalDateTime>.day: Expect<Int>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ import kotlin.test.Test

class LocalDateTimeExpectationSamples {

@Test
fun yearFeature() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.year.toEqual(2021)

fails {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.year.notToEqual(2021)
}
}

@Test
fun year() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
Expand All @@ -22,13 +33,24 @@ class LocalDateTimeExpectationSamples {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.year {
// subject inside this block is of type Int (actually 2021)
notToEqual(2022)
notToEqual(2021)
toBeGreaterThan(2022)
toBeLessThan(2020)
}
}
}

@Test
fun monthFeature() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.month.toEqual(Month.OCTOBER.value)

fails {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.month.toEqual(Month.SEPTEMBER.value)
}
}

@Test
fun month() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
Expand All @@ -48,6 +70,17 @@ class LocalDateTimeExpectationSamples {
}
}

@Test
fun dayOfWeekFeature() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.dayOfWeek.toEqual(DayOfWeek.SATURDAY)

fails {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.dayOfWeek.toEqual(DayOfWeek.MONDAY)
}
}

@Test
fun dayOfWeek() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
Expand All @@ -67,6 +100,17 @@ class LocalDateTimeExpectationSamples {
}
}

@Test
fun dayFeature() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.day.toEqual(9)

fails {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.day.toEqual(5)
}
}

@Test
fun day() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
Expand All @@ -85,5 +129,4 @@ class LocalDateTimeExpectationSamples {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import java.time.LocalDateTime
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.LocalDateTimeExpectationSamples.yearFeature
*
* @since 0.12.0
*/
val Expect<LocalDateTime>.year: Expect<Int>
Expand All @@ -42,6 +44,8 @@ infix fun Expect<LocalDateTime>.year(assertionCreator: Expect<Int>.() -> Unit):
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.LocalDateTimeExpectationSamples.monthFeature
*
* @since 0.12.0
*/
val Expect<LocalDateTime>.month: Expect<Int>
Expand All @@ -67,6 +71,8 @@ infix fun Expect<LocalDateTime>.month(assertionCreator: Expect<Int>.() -> Unit):
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.LocalDateTimeExpectationSamples.dayOfWeekFeature
*
* @since 0.12.0
*/
val Expect<LocalDateTime>.dayOfWeek: Expect<DayOfWeek>
Expand All @@ -92,6 +98,8 @@ infix fun Expect<LocalDateTime>.dayOfWeek(assertionCreator: Expect<DayOfWeek>.()
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.LocalDateTimeExpectationSamples.dayFeature
*
* @since 0.12.0
*/
val Expect<LocalDateTime>.day: Expect<Int>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ch.tutteli.atrium.api.infix.en_GB.samples

import ch.tutteli.atrium.api.infix.en_GB.*
import ch.tutteli.atrium.api.infix.en_GB.workaround.it
import ch.tutteli.atrium.api.verbs.internal.expect
import java.time.DayOfWeek
import java.time.LocalDateTime
Expand All @@ -9,6 +10,15 @@ import kotlin.test.Test

class LocalDateTimeExpectationSamples {

@Test
fun yearFeature() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)).year toEqual 2021

fails {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)).year toEqual 2022
}
}

@Test
fun year() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) year {
Expand All @@ -20,13 +30,24 @@ class LocalDateTimeExpectationSamples {
fails {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) year {
// subject inside this block is of type Int (actually 2021)
it notToEqual 2022
it notToEqual 2021
it toBeGreaterThan 2022
it toBeLessThan 2020
}
}
}

@Test
fun monthFeature() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.month toEqual Month.OCTOBER.value

fails {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.month toEqual Month.SEPTEMBER.value
}
}

@Test
fun month() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) month {
Expand All @@ -44,6 +65,17 @@ class LocalDateTimeExpectationSamples {
}
}

@Test
fun dayOfWeekFeature() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.dayOfWeek toEqual DayOfWeek.SATURDAY

fails {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56))
.dayOfWeek toEqual DayOfWeek.MONDAY
}
}

@Test
fun dayOfWeek() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) dayOfWeek {
Expand All @@ -61,6 +93,15 @@ class LocalDateTimeExpectationSamples {
}
}

@Test
fun dayFeature() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)).day toEqual 9

fails {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)).day toEqual 5
}
}

@Test
fun day() {
expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) day {
Expand All @@ -77,5 +118,4 @@ class LocalDateTimeExpectationSamples {
}
}
}

}

0 comments on commit de10e1a

Please sign in to comment.