diff options
| author | mo khan <mo@mokhan.ca> | 2019-08-05 17:00:07 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2019-08-05 17:00:07 -0600 |
| commit | f1f1f634fa2eaffafbe5215ef9e156fb3a231dfd (patch) | |
| tree | a61a41b2ff8cc1cd0f163d6d3f21f0467d56b7a5 | |
| parent | ccbe674849303611e61c37c384d79394c632a3ef (diff) | |
add failing test to help flush out design of delay method
| -rw-r--r-- | src/Q10/TrainTimeTable.java | 4 | ||||
| -rw-r--r-- | src/Q10/TrainTimeTableTest.java | 46 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/Q10/TrainTimeTable.java b/src/Q10/TrainTimeTable.java index 996d81e..ab5dfa9 100644 --- a/src/Q10/TrainTimeTable.java +++ b/src/Q10/TrainTimeTable.java @@ -32,6 +32,10 @@ public class TrainTimeTable { station.getCity(), station.getArrival(), station.getDeparture(), station.getDay())); } + public Station stationIn(String city) { + return null; + } + public static void main(String[] args) { System.out.println("=== Question 10 ==="); LinkedList<Station> stations = new LinkedList<Station>(); diff --git a/src/Q10/TrainTimeTableTest.java b/src/Q10/TrainTimeTableTest.java new file mode 100644 index 0000000..ae88676 --- /dev/null +++ b/src/Q10/TrainTimeTableTest.java @@ -0,0 +1,46 @@ +package ca.mokhan.test; + +import Q10.*; +import java.io.*; +import java.text.*; +import java.util.*; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +public class TrainTimeTableTest extends TestCase { + private TrainTimeTable subject; + private LinkedList<Station> stations = + new LinkedList<Station>( + Arrays.asList( + new Station("Vancouver", null, new Date(), 1), + new Station("Kamloops", new Date(), new Date(), 2), + new Station("Jasper", new Date(), new Date(), 2), + new Station("Edmonton", new Date(), new Date(), 2), + new Station("Saskatchewan", new Date(), new Date(), 3), + new Station("Winnipeg", new Date(), new Date(), 3), + new Station("Sioux Lookout", new Date(), new Date(), 4), + new Station("Hornepayne", new Date(), new Date(), 4), + new Station("Capreol", new Date(), new Date(), 5), + new Station("Toronto", new Date(), new Date(), 5))); + + public TrainTimeTableTest(String testName) { + super(testName); + this.subject = new TrainTimeTable(this.stations); + } + + public static Test suite() { + return new TestSuite(TrainTimeTableTest.class); + } + + public void test_delay_edmonton_30minutes() { + this.subject.delay("Edmonton", 30); + + Station station = this.subject.stationIn("Edmonton"); + assertNotNull(station); + assertEquals("Edmonton", station.getCity()); + assertEquals("23:30", station.getArrival()); + assertEquals("00:29", station.getDeparture()); + assertEquals(3, station.getDay()); + } +} |
