Skip to content

Commit

Permalink
Add samples for localDateAssertions expect values (robstoll#996)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhushikesh committed Oct 10, 2021
1 parent 5d2d1be commit 3216f63
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import java.time.LocalDate
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateExpectationSamples.yearFeature
*
* @since 0.9.0
*/
val Expect<LocalDate>.year: Expect<Int>
Expand All @@ -41,6 +43,8 @@ fun Expect<LocalDate>.year(assertionCreator: Expect<Int>.() -> Unit): Expect<Loc
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateExpectationSamples.monthFeature
*
* @since 0.9.0
*/
val Expect<LocalDate>.month: Expect<Int>
Expand All @@ -66,6 +70,8 @@ fun Expect<LocalDate>.month(assertionCreator: Expect<Int>.() -> Unit): Expect<Lo
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateExpectationSamples.dayOfWeekFeature
*
* @since 0.9.0
*/
val Expect<LocalDate>.dayOfWeek: Expect<DayOfWeek>
Expand All @@ -92,6 +98,8 @@ fun Expect<LocalDate>.dayOfWeek(assertionCreator: Expect<DayOfWeek>.() -> Unit):
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.LocalDateExpectationSamples.dayFeature
*
* @since 0.9.0
*/
val Expect<LocalDate>.day: Expect<Int>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,121 @@ import kotlin.test.Test

class LocalDateExpectationSamples {

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

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

@Test
fun year() {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.year {
// subject inside this block is of type Int (actually 2021)
toEqual(2021)
toBeGreaterThan(2020)
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.year {
notToEqual(2022)
// subject inside this block is of type Int (actually 2021)
notToEqual(2021)
toBeGreaterThan(2022)
toBeLessThan(2020)
}
}
}

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

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

@Test
fun month() {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.month {
// subject inside this block is of type Int (actually Month.OCTOBER.value i.e. 10)
toEqual(Month.OCTOBER.value)
notToEqual(Month.SEPTEMBER.value)
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.month {
// subject inside this block is of type Int (actually Month.OCTOBER.value i.e. 10)
toEqual(Month.SEPTEMBER.value)
notToEqual(Month.OCTOBER.value)
}
}
}

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

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

@Test
fun dayOfWeek() {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.dayOfWeek {
// subject inside this block is of type DayOfWeek (actually SATURDAY)
toEqual(DayOfWeek.SATURDAY)
notToEqual(DayOfWeek.SUNDAY)
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.dayOfWeek {
// subject inside this block is of type DayOfWeek (actually SATURDAY)
toEqual(DayOfWeek.MONDAY)
notToEqual(DayOfWeek.SATURDAY)
}
}
}

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

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

@Test
fun day() {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.day {
// subject inside this block is of type Int (actually 9)
toEqual(9)
toBeGreaterThan(5)
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9))
.day {
// subject inside this block is of type Int (actually 9)
toEqual(5)
toBeLessThan(7)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import java.time.LocalDate
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.LocalDateExpectationSamples.yearFeature
*
* @since 0.12.0
*/
val Expect<LocalDate>.year: Expect<Int>
Expand All @@ -42,6 +44,8 @@ infix fun Expect<LocalDate>.year(assertionCreator: Expect<Int>.() -> Unit): Expe
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.LocalDateExpectationSamples.monthFeature
*
* @since 0.12.0
*/
val Expect<LocalDate>.month: Expect<Int>
Expand All @@ -67,6 +71,8 @@ infix fun Expect<LocalDate>.month(assertionCreator: Expect<Int>.() -> Unit): Exp
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.LocalDateExpectationSamples.dayOfWeekFeature
*
* @since 0.12.0
*/
val Expect<LocalDate>.dayOfWeek: Expect<DayOfWeek>
Expand All @@ -93,6 +99,8 @@ infix fun Expect<LocalDate>.dayOfWeek(assertionCreator: Expect<DayOfWeek>.() ->
*
* @return The newly created [Expect] for the extracted feature.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.LocalDateExpectationSamples.dayFeature
*
* @since 0.12.0
*/
val Expect<LocalDate>.day: Expect<Int>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,112 @@ import kotlin.test.Test

class LocalDateExpectationSamples {

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

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

@Test
fun year() {
expect(LocalDate.of(2021, Month.OCTOBER, 9)) year {
// subject inside this block is of type Int (actually 2021)
it toEqual 2021
it toBeGreaterThan 2020
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9)) year {
it notToEqual 2022
// subject inside this block is of type Int (actually 2021)
it notToEqual 2021
it toBeGreaterThan 2022
it toBeLessThan 2020
}
}
}

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

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

@Test
fun month() {
expect(LocalDate.of(2021, Month.OCTOBER, 9)) month {
// subject inside this block is of type Int (actually Month.OCTOBER.value i.e. 10)
it toEqual Month.OCTOBER.value
it notToEqual Month.SEPTEMBER.value
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9)) month {
// subject inside this block is of type Int (actually Month.OCTOBER.value i.e. 10)
it toEqual Month.SEPTEMBER.value
it notToEqual Month.OCTOBER.value
}
}
}

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

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

@Test
fun dayOfWeek() {
expect(LocalDate.of(2021, Month.OCTOBER, 9)) dayOfWeek {
// subject inside this block is of type DayOfWeek (actually SATURDAY)
it toEqual DayOfWeek.SATURDAY
it notToEqual DayOfWeek.SUNDAY
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9)) dayOfWeek {
// subject inside this block is of type DayOfWeek (actually SATURDAY)
it toEqual DayOfWeek.MONDAY
it notToEqual DayOfWeek.SATURDAY
}
}
}

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

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

@Test
fun day() {
expect(LocalDate.of(2021, Month.OCTOBER, 9)) day {
// subject inside this block is of type Int (actually 9)
it toEqual 9
it toBeGreaterThan 5
}

fails {
expect(LocalDate.of(2021, Month.OCTOBER, 9)) day {
// subject inside this block is of type Int (actually 9)
it toEqual 5
it toBeLessThan 7
}
}
}

}

0 comments on commit 3216f63

Please sign in to comment.