public void ProcessRightCommand_WhenRobotIsPlacedOnTheTable_ShouldTurnTheRobotToTheRight() { var robot = new Domain.Robot(new RobotBrain()); PlaceCommandParameter initialPlacement = new PlaceCommandParameter(0, 0, Direction.NORTH.ToString()); robot.Process(new Command(CommandType.PLACE, initialPlacement)); robot.Process(new Command(CommandType.RIGHT)); Assert.That(robot.Orientation.Direction, Is.EqualTo(Direction.EAST)); }
public void Place_WhenGivenPositionAndDirectionAreCorrect_ProcessCommand() { var brain = new RobotBrain(); PlaceCommandParameter placementParam = new PlaceCommandParameter(1, 1, "north"); var position = brain.Place(placementParam); Assert.That(position, Is.Not.Null); Assert.That(position.location.X, Is.EqualTo(placementParam.X)); Assert.That(position.location.Y, Is.EqualTo(placementParam.Y)); Assert.That(position.orientation.Direction.ToString().Equals(placementParam.Direction, StringComparison.CurrentCultureIgnoreCase)); }
public void Place_WhenGivenDirectionIsInvalid_ShouldThrownException() { var brain = new RobotBrain(); SimulationException exception = null; try { PlaceCommandParameter placementParam = new PlaceCommandParameter(1, 1, "north-ish"); brain.Place(placementParam); } catch (SimulationException e) { exception = e; } Assert.That(exception, Is.Not.Null); }
public void ProcessPlaceCommand_WhenCommandHasInvalidLocation_ShouldIgnorePlaceCommand() { var robot = new Domain.Robot(new Domain.RobotBrain()); SimulationException exception = null; try { Domain.PlaceCommandParameter placementParam = new PlaceCommandParameter(-1, -1, Direction.NORTH.ToString()); robot.Process(new Domain.Command(CommandType.PLACE, placementParam)); } catch (SimulationException e) { exception = e; } Assert.That(exception, Is.Not.Null); Assert.That(exception.Message, Is.EqualTo(ErrorMessages.InvalidLocationParameters)); }
public void ProcessPlaceCommand_WhenCommandHasInvalidDirection_ShouldIgnorePlaceCommand() { var robot = new Domain.Robot(new RobotBrain()); SimulationException exception = null; try { PlaceCommandParameter placementParam = new PlaceCommandParameter(1, 1, "north-ish"); robot.Process(new Command(CommandType.PLACE, placementParam)); } catch (SimulationException e) { exception = e; } Assert.That(exception, Is.Not.Null); Assert.That(exception.Message, Is.EqualTo(ErrorMessages.InvalidDirectionMessage)); }