public void TestThatRoadColorGetsSet() { Intersection i = new Intersection(new Point(1, 1)); Intersection i2 = new Intersection(new Point(1, 2)); Connection c = new Connection(i, i2); c.setRoadColor(Color.HotPink); Assert.AreEqual(Color.HotPink, c.getRoadColor()); }
public void addConnection(Connection spot) { bool wasAdded = false; int roadsIndex = 0; List<List<Connection>> addedRoads = new List<List<Connection>>(); foreach (List<Connection> intList in roads) { int intListIndex = 0; foreach (Connection road in intList) { if (road.getIntersectionLeftOrTop().Equals(spot.getIntersectionLeftOrTop()) || road.getIntersectionLeftOrTop().Equals(spot.getIntersectionRightOrBot()) || road.getIntersectionRightOrBot().Equals(spot.getIntersectionRightOrBot()) || (road.getIntersectionRightOrBot().Equals(spot.getIntersectionLeftOrTop())) & intListIndex == intList.Count - 1) { intList.Add(spot); wasAdded = true; if (intList.Count() > roads[this.longestRoadIndex].Count()) { longestRoadIndex = roadsIndex; } break; } else if (road.getIntersectionLeftOrTop().Equals(spot.getIntersectionLeftOrTop()) || road.getIntersectionLeftOrTop().Equals(spot.getIntersectionRightOrBot()) || road.getIntersectionRightOrBot().Equals(spot.getIntersectionRightOrBot()) || (road.getIntersectionRightOrBot().Equals(spot.getIntersectionLeftOrTop())) & intListIndex != intList.Count - 1) { List<Connection> newList = new List<Connection>(); for (int i = 0; i <= intListIndex; i++) { newList.Add(intList[i]); } newList.Add(spot); addedRoads.Add(newList); wasAdded = true; if (newList.Count() > roads[this.longestRoadIndex].Count()) { longestRoadIndex = roadsIndex; } break; } intListIndex++; } roadsIndex++; } if (addedRoads.Count != 0) { foreach (List<Connection> road in addedRoads) { roads.Add(road); } } if (!wasAdded) { roads.Add(new List<Connection> {spot}); } }
public void TestGetCoordinates() { var target = new Connection(new Intersection(new Point(2, 2)), new Intersection(new Point(2, 3))); Assert.AreNotEqual((new Point(2, 2)), target.getCoords()); }