summaryrefslogtreecommitdiff
path: root/src/Q10/TrainTimeTableTest.java
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2019-08-05 17:00:07 -0600
committermo khan <mo@mokhan.ca>2019-08-05 17:00:07 -0600
commitf1f1f634fa2eaffafbe5215ef9e156fb3a231dfd (patch)
treea61a41b2ff8cc1cd0f163d6d3f21f0467d56b7a5 /src/Q10/TrainTimeTableTest.java
parentccbe674849303611e61c37c384d79394c632a3ef (diff)
add failing test to help flush out design of delay method
Diffstat (limited to 'src/Q10/TrainTimeTableTest.java')
-rw-r--r--src/Q10/TrainTimeTableTest.java46
1 files changed, 46 insertions, 0 deletions
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());
+ }
+}