1 package net.pterodactylus.rhynodge.webpages.weather.wettercom
3 import org.hamcrest.MatcherAssert.assertThat
4 import org.hamcrest.Matchers.`is`
6 import java.time.Instant
7 import java.time.ZoneId
8 import java.time.ZonedDateTime
11 * Unit test for [WetterComState].
13 * @author [David ‘Bombe’ Roden](mailto:bombe@pterodactylus.net)
15 class WetterComStateTest {
18 fun statesWithoutHoursEqualOneAnother() {
19 val now = Instant.now().atZone(ZoneId.of("Europe/Berlin"))
20 val firstState = WetterComState(ZonedDateTime.from(now))
21 val secondState = WetterComState(ZonedDateTime.from(now))
22 assertThat(firstState, `is`(secondState))
26 fun statesWithTheSameHoursAreEqual() {
27 val now = Instant.now().atZone(ZoneId.of("Europe/Berlin"))
28 val firstState = WetterComState(ZonedDateTime.from(now))
29 firstState.addHour(HourState(0, 10.0, 0.05, 0.0, WindDirection.NORTH, 5.0, "Fine", "http://1"))
30 firstState.addHour(HourState(1, 12.0, 0.1, 2.0, WindDirection.WEST, 8.0, "Superb", "http://2"))
31 val secondState = WetterComState(ZonedDateTime.from(now))
32 secondState.addHour(HourState(0, 10.0, 0.05, 0.0, WindDirection.NORTH, 5.0, "Fine", "http://1"))
33 secondState.addHour(HourState(1, 12.0, 0.1, 2.0, WindDirection.WEST, 8.0, "Superb", "http://2"))
34 assertThat(firstState, `is`(secondState))
38 fun iteratingDeliversHourStates() {
39 val now = Instant.now().atZone(ZoneId.of("Europe/Berlin"))
40 val firstState = WetterComState(ZonedDateTime.from(now))
41 firstState.addHour(HourState(0, 10.0, 0.05, 0.0, WindDirection.NORTH, 5.0, "Fine", "http://1"))
42 firstState.addHour(HourState(1, 12.0, 0.1, 2.0, WindDirection.WEST, 8.0, "Superb", "http://2"))
43 assertThat(firstState.iterator().asSequence().toList(), `is`(firstState.hours as Iterable<HourState>))