| 1 | |
|---|
| 2 | package tmcsim.highwaymodel; |
|---|
| 3 | |
|---|
| 4 | import tmcsim.highwaymodel.LoopDetector; |
|---|
| 5 | import tmcsim.highwaymodel.Station; |
|---|
| 6 | import tmcsim.highwaymodel.Highway; |
|---|
| 7 | import tmcsim.highwaymodel.Station.DIRECTION; |
|---|
| 8 | import java.util.ArrayList; |
|---|
| 9 | import java.util.Set; |
|---|
| 10 | import junit.framework.TestCase; |
|---|
| 11 | |
|---|
| 12 | /** |
|---|
| 13 | * |
|---|
| 14 | * @author jdalbey |
|---|
| 15 | */ |
|---|
| 16 | public class HighwayTest extends TestCase |
|---|
| 17 | { |
|---|
| 18 | Station alpha; |
|---|
| 19 | Station beta; |
|---|
| 20 | public HighwayTest(String testName) |
|---|
| 21 | { |
|---|
| 22 | super(testName); |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | @Override |
|---|
| 26 | protected void setUp() throws Exception |
|---|
| 27 | { |
|---|
| 28 | super.setUp(); |
|---|
| 29 | alpha = new Station(1,2,3,"A",new ArrayList<LoopDetector>(), 4, Station.DIRECTION.NORTH, 1.0); |
|---|
| 30 | beta = new Station(1,2,3,"B",new ArrayList<LoopDetector>(), 4, Station.DIRECTION.SOUTH, 1.0); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | @Override |
|---|
| 34 | protected void tearDown() throws Exception |
|---|
| 35 | { |
|---|
| 36 | super.tearDown(); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | public void testToString() |
|---|
| 40 | { |
|---|
| 41 | System.out.println("toString"); |
|---|
| 42 | Highway instance = new Highway(5,null); |
|---|
| 43 | String expResult = "5"; |
|---|
| 44 | String result = instance.toString(); |
|---|
| 45 | assertEquals(expResult, result); |
|---|
| 46 | } |
|---|
| 47 | public void testDirections() |
|---|
| 48 | { |
|---|
| 49 | ArrayList<Station> stations = new ArrayList<Station>(); |
|---|
| 50 | stations.add(alpha); |
|---|
| 51 | stations.add(beta); |
|---|
| 52 | Highway h1 = new Highway(5,stations); |
|---|
| 53 | Set<DIRECTION> dirs = h1.availDirs; |
|---|
| 54 | assertTrue(dirs.contains(DIRECTION.NORTH)); |
|---|
| 55 | assertTrue(dirs.contains(DIRECTION.SOUTH)); |
|---|
| 56 | } |
|---|
| 57 | } |
|---|