Skip to content

Commit

Permalink
Add samples for localDateAssertions of api-fluent (robstoll#996)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhushikesh committed Oct 9, 2021
1 parent b1b8b6e commit 6854890
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ val Expect<LocalDate>.year: Expect<Int>
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateExpectationSamples.year
*
* @since 0.9.0
*/
fun Expect<LocalDate>.year(assertionCreator: Expect<Int>.() -> Unit): Expect<LocalDate> =
Expand All @@ -51,6 +53,8 @@ val Expect<LocalDate>.month: Expect<Int>
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateExpectationSamples.month
*
* @since 0.9.0
*/
fun Expect<LocalDate>.month(assertionCreator: Expect<Int>.() -> Unit): Expect<LocalDate> =
Expand All @@ -74,6 +78,8 @@ val Expect<LocalDate>.dayOfWeek: Expect<DayOfWeek>
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateExpectationSamples.dayOfWeek
*
* @since 0.9.0
*/
fun Expect<LocalDate>.dayOfWeek(assertionCreator: Expect<DayOfWeek>.() -> Unit): Expect<LocalDate> =
Expand All @@ -98,6 +104,8 @@ val Expect<LocalDate>.day: Expect<Int>
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateExpectationSamples.day
*
* @since 0.9.0
*/
fun Expect<LocalDate>.day(assertionCreator: Expect<Int>.() -> Unit): Expect<LocalDate> =
Expand Down
Original file line number Diff line number Diff line change
@@ -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.LocalDate
import java.time.Month
import kotlin.test.Test

class LocalDateExpectationSamples {

@Test
fun year() {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.year {
toEqual(2021)
toBeGreaterThan(2020)
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.year {
notToEqual(2022)
toBeGreaterThan(2022)
toBeLessThan(2020)
}
}
}

@Test
fun month() {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.month {
toEqual(Month.OCTOBER.value)
notToEqual(Month.SEPTEMBER.value)
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.month {
toEqual(Month.SEPTEMBER.value)
notToEqual(Month.OCTOBER.value)
}
}
}

@Test
fun dayOfWeek() {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.dayOfWeek {
toEqual(DayOfWeek.SATURDAY)
notToEqual(DayOfWeek.SUNDAY)
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.dayOfWeek {
toEqual(DayOfWeek.MONDAY)
notToEqual(DayOfWeek.SATURDAY)
}
}
}

@Test
fun day() {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.day {
toEqual(9)
toBeGreaterThan(5)
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.day {
toEqual(5)
toBeLessThan(7)
}
}
}

}

0 comments on commit 6854890

Please sign in to comment.