public void MoveInDirectionTest() { var pos = new Position { X = 0, Y = 0, Direction = Directions.E }; Assert.IsTrue(StateHelper.MoveInDirection(pos).X == pos.X + 1); pos = new Position { X = 0, Y = 0, Direction = Directions.W }; Assert.IsTrue(StateHelper.MoveInDirection(pos).X == pos.X - 1); pos = new Position { X = 0, Y = 0, Direction = Directions.N }; Assert.IsTrue(StateHelper.MoveInDirection(pos).Y == pos.Y - 1); pos = new Position { X = 0, Y = 0, Direction = Directions.S }; Assert.IsTrue(StateHelper.MoveInDirection(pos).Y == pos.Y + 1); }
public void GetNewPositionTest() { var actualMove = Moves.M; var actualPosition = new Position { X = 0, Y = 0, Direction = Directions.N }; var newPos1 = StateHelper.CalculateNewPosition(actualMove, actualPosition); var newPos2 = StateHelper.MoveInDirection(actualPosition); Assert.AreEqual(newPos1, newPos2); actualMove = Moves.L; actualPosition = new Position { X = 0, Y = 0, Direction = Directions.N }; newPos1 = StateHelper.CalculateNewPosition(actualMove, actualPosition); newPos2 = StateHelper.MoveInDirection(actualPosition); Assert.AreNotEqual(newPos1, newPos2); newPos1 = StateHelper.CalculateNewPosition(actualMove, actualPosition); newPos2 = StateHelper.Turn(actualMove, actualPosition); Assert.AreEqual(newPos1, newPos2); }