public void IsWithinBoundary(int x, int y, bool expectedResult) { var world = new BoundedWorld(5, 5); var actualResult = world.IsWithinBoundary(new Coordinate(x, y)); Assert.Equal(expectedResult, actualResult); }
public void EmptyCommandDoesnotMoveRover() { var rover = new Rover(); var world = new BoundedWorld(5, 5); var commandModule = new CommandModule(rover, world.IsWithinBoundary); commandModule.Execute("", IgnoreErrors); Assert.Equal(0, rover.Location.X); Assert.Equal(0, rover.Location.Y); }
public void RoverFollowsCompleteCommandsToExpectedCoordinate(string command, int expectedX, int expectedY, Direction expectedDirection) { var rover = new Rover(); var world = new BoundedWorld(5, 5); var commandModule = new CommandModule(rover, world.IsWithinBoundary); commandModule.Execute(command, IgnoreErrors); Assert.Equal(expectedX, rover.Location.X); Assert.Equal(expectedY, rover.Location.Y); Assert.Equal(expectedDirection, rover.Direction); }
public void RoverFollowsCompleteCommandsToExpectedCoordinateWithFailReportingPolicy(string command, int expectedX, int expectedY, Direction expectedDirection, bool errorsOccured) { var rover = new Rover(); var world = new BoundedWorld(5, 5); var policy = new StopOnErrorPolicy(); var commandModule = new CommandModule(rover, world.IsWithinBoundary); var errorHappened = false; commandModule.Execute(command, () => { errorHappened = true; return(false); }); Assert.Equal(errorsOccured, errorHappened); Assert.Equal(expectedX, rover.Location.X); Assert.Equal(expectedY, rover.Location.Y); Assert.Equal(expectedDirection, rover.Direction); //commandModule.Execute(command, policy.StopOnError); //Assert.Equal(errorsOccured, policy.ErrorHappened); }