public void WrapAtEdgeWhenMoveBackward(Coordinate coordinate, char direction, World world, int expectedXCoord, int expectedYCoord) { var rover = new Rover(coordinate, direction, world); rover.MoveBackward(); Assert.Equal(expectedXCoord, rover.GetCoordinate().GetXCoordinate()); Assert.Equal(expectedYCoord, rover.GetCoordinate().GetYCoordinate()); }
public void MoveBackward(int initialX, int initialY, char initialDirection, int expectedX, int expectedY, char expectedDirection) { var coordinate = new Coordinate(initialX, initialY); var world = new World(5, 5); var rover = new Rover(coordinate, initialDirection, world); rover.MoveBackward(); Assert.Equal(expectedX, rover.GetCoordinate().GetXCoordinate()); Assert.Equal(expectedY, rover.GetCoordinate().GetYCoordinate()); Assert.Equal(expectedDirection, rover.GetDirection()); }
public void NotMoveBackwardIfThereIsObstacle(int xCoord, int yCoord, char direction, World world, Coordinate obstacle) { var coordinate = new Coordinate(xCoord, yCoord); world.SetObstacle(obstacle); var rover = new Rover(coordinate, direction, world); var exception = Assert.Throws <Exception>(() => rover.MoveBackward()); Assert.Equal($"Bump into obstacle at {obstacle.GetXCoordinate()},{obstacle.GetYCoordinate()}", exception.Message); Assert.Equal(xCoord, rover.GetCoordinate().GetXCoordinate()); Assert.Equal(yCoord, rover.GetCoordinate().GetYCoordinate()); }