public void RoverEngine_MoveForward_From11W_To01W() { var engine = new RoverEngine(1, 1, EDirection.W, _gridHeight, _gridWidth, _mockObstacleDetector.Object); var moveResult = engine.MoveForward(); Assert.AreEqual(0, moveResult.Position.X); Assert.AreEqual(1, moveResult.Position.Y); Assert.AreEqual(EDirection.W, moveResult.Position.Direction); }
public void RoverEngine_MoveForward_W_ObstacleDetected_ReportObstacle() { _mockObstacleDetector.Setup(m => m.CanMove(0, 1)).Returns(false); var engine = new RoverEngine(1, 1, EDirection.W, _gridHeight, _gridWidth, _mockObstacleDetector.Object); var moveResult = engine.MoveForward(); Assert.AreEqual(1, moveResult.Position.X); Assert.AreEqual(1, moveResult.Position.Y); Assert.AreEqual(EDirection.W, moveResult.Position.Direction); Assert.IsTrue(moveResult.IsObstacleDetected); }
public void RoverEngine_WrapWest_MoveForward150_From15W_To51_5W() { var engine = new RoverEngine(1, 5, EDirection.W, _gridHeight, _gridWidth, _mockObstacleDetector.Object); for (int i = 0; i < 150; i++) { engine.MoveForward(); } var newPosition = engine.GetPosition(); Assert.AreEqual(51, newPosition.X); Assert.AreEqual(5, newPosition.Y); Assert.AreEqual(EDirection.W, newPosition.Direction); }
public void RoverEngine_WrapWest_MoveForward100_ArriveAtSameSpot() { var engine = new RoverEngine(0, 0, EDirection.W, _gridHeight, _gridWidth, _mockObstacleDetector.Object); for (int i = 0; i < 100; i++) { engine.MoveForward(); } var newPosition = engine.GetPosition(); Assert.AreEqual(0, newPosition.X); Assert.AreEqual(0, newPosition.Y); Assert.AreEqual(EDirection.W, newPosition.Direction); }