public void CartMovingTest() { // Track // 0123456789 // 0 >-\ /\ // 1 +-++ |+- // 2 \-/ var cart = new Day13.Cart(Day13.Directions.east, 0, 0); var tracks = new Day13.Track[] { Day13.Track.horizontal, Day13.Track.curveBackward, Day13.Track.intersection, Day13.Track.horizontal, Day13.Track.intersection, Day13.Track.intersection, Day13.Track.curveBackward, Day13.Track.horizontal, Day13.Track.curveForward, Day13.Track.vertical, Day13.Track.curveForward, Day13.Track.curveBackward, Day13.Track.intersection, Day13.Track.horizontal }; var expectedX = new int[] { 1, 2, 2, 3, 4, 5, 5, 6, 7, 7, 7, 8, 8, 9 }; var expectedY = new int[] { 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 0, 0, 1, 1 }; for (int i = 0; i < tracks.Length; i++) { cart.Move(tracks[i]); Assert.AreEqual(expectedX[i], cart.X); Assert.AreEqual(expectedY[i], cart.Y); } }
public void CartTurningTest() { var cart = new Day13.Cart(Day13.Directions.south, 0, 0); // Clockwise cart.TurnRight(); Assert.AreEqual(Day13.Directions.west, cart.Direction); cart.TurnRight(); Assert.AreEqual(Day13.Directions.north, cart.Direction); cart.TurnRight(); Assert.AreEqual(Day13.Directions.east, cart.Direction); // Counter-clockwise cart.TurnLeft(); Assert.AreEqual(Day13.Directions.north, cart.Direction); cart.TurnLeft(); Assert.AreEqual(Day13.Directions.west, cart.Direction); cart.TurnLeft(); Assert.AreEqual(Day13.Directions.south, cart.Direction); }