diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/localDateTimeAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/localDateTimeAssertions.kt index 8b502c1d31..0adbe3f2b9 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/localDateTimeAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/localDateTimeAssertions.kt @@ -29,6 +29,8 @@ val Expect.year: Expect * * @return an [Expect] for the subject of `this` expectation. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateTimeExpectationSamples.year + * * @since 0.9.0 */ fun Expect.year(assertionCreator: Expect.() -> Unit): Expect = @@ -52,6 +54,8 @@ val Expect.month: Expect * * @return an [Expect] for the subject of `this` expectation. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateTimeExpectationSamples.month + * * @since 0.9.0 */ fun Expect.month(assertionCreator: Expect.() -> Unit): Expect = @@ -75,6 +79,8 @@ val Expect.dayOfWeek: Expect * * @return an [Expect] for the subject of `this` expectation. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateTimeExpectationSamples.dayOfWeek + * * @since 0.9.0 */ fun Expect.dayOfWeek(assertionCreator: Expect.() -> Unit): Expect = @@ -98,6 +104,8 @@ val Expect.day: Expect * * @return an [Expect] for the subject of `this` expectation. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateTimeExpectationSamples.day + * * @since 0.9.0 */ fun Expect.day(assertionCreator: Expect.() -> Unit): Expect = diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/LocalDateTimeExpectationSamples.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/LocalDateTimeExpectationSamples.kt new file mode 100644 index 0000000000..a74553212a --- /dev/null +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/LocalDateTimeExpectationSamples.kt @@ -0,0 +1,81 @@ +package ch.tutteli.atrium.api.fluent.en_GB.samples + +import ch.tutteli.atrium.api.fluent.en_GB.* +import ch.tutteli.atrium.api.verbs.internal.expect +import java.time.DayOfWeek +import java.time.LocalDateTime +import java.time.Month +import kotlin.test.Test + +class LocalDateTimeExpectationSamples { + + @Test + fun year() { + expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) + .year { + toEqual(2021) + toBeGreaterThan(2020) + } + + fails { + expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) + .year { + notToEqual(2022) + toBeGreaterThan(2022) + toBeLessThan(2020) + } + } + } + + @Test + fun month() { + expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) + .month { + toEqual(Month.OCTOBER.value) + notToEqual(Month.SEPTEMBER.value) + } + + fails { + expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) + .month { + toEqual(Month.SEPTEMBER.value) + notToEqual(Month.OCTOBER.value) + } + } + } + + @Test + fun dayOfWeek() { + expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) + .dayOfWeek { + toEqual(DayOfWeek.SATURDAY) + notToEqual(DayOfWeek.SUNDAY) + } + + fails { + expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) + .dayOfWeek { + toEqual(DayOfWeek.MONDAY) + notToEqual(DayOfWeek.SATURDAY) + } + } + } + + @Test + fun day() { + expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) + .day { + toEqual(9) + toBeGreaterThan(5) + } + + fails { + expect(LocalDateTime.of(2021, Month.OCTOBER, 9, 11, 56)) + .day { + toEqual(5) + toBeLessThan(7) + } + } + } + +}