public void ShouldMarkLostLandmark() { // Arrange var map = new Mock <IPlanetMap>(); var initialPosition = Coordinates.Zero; var robot = new Robot(initialPosition, Orientation.North); var destination = new Coordinates(0, 1); var lostLandmark = new LostLandmark(destination); map.Setup(m => m.GetNextCoordinates(It.IsAny <Coordinates>(), It.IsAny <Orientation>())) .Returns(() => destination); map.Setup(m => m.GetLandmarks()) .Returns(() => new Dictionary <Coordinates, IEnumerable <Landmark> > { { robot.Coordinates, new Landmark[0] } }); map.Setup(m => m.IsOutOfBounds(It.IsAny <Coordinates>())) .Returns(() => true); // Act MoveForwardAction.Instance.Execute(robot, map.Object); // Assert // Robot should have trouble // Landmark should be added robot.Troubles.OfType <LostRobotTrouble>().Should().HaveCount(1); map.Verify(mock => mock.AddLandmark(It.IsAny <Coordinates>(), It.IsAny <Landmark>()), Times.Once()); }
public void ShouldIgnoreIfRobotWillBeLost() { // Arrange var map = new Mock <IPlanetMap>(); var initialPosition = Coordinates.Zero; var robot = new Robot(initialPosition, Orientation.North); var destination = new Coordinates(0, 1); var lostLandmark = new LostLandmark(destination); map.Setup(m => m.GetNextCoordinates(It.IsAny <Coordinates>(), It.IsAny <Orientation>())) .Returns(() => destination); map.Setup(m => m.GetLandmarks()) .Returns(() => new Dictionary <Coordinates, IEnumerable <Landmark> > { { robot.Coordinates, new[] { lostLandmark } } }); // Act MoveForwardAction.Instance.Execute(robot, map.Object); // Assert // Robot should not move robot.Coordinates.Should().Be(initialPosition); }