public void Robot_TestUndoWhenWhenRobotIsStuckAgainstSouthWall_RobotReportsOrignalPosition() { Robot robot = new Robot(); Tabletop table = new Tabletop(5, 5); RobotCommander commander = new RobotCommander(); PlaceCommand place = new PlaceCommand(robot, table); place.Direction = "North"; MoveCommand move = new MoveCommand(robot, table); RightCommand right = new RightCommand(robot); LeftCommand left = new LeftCommand(robot); commander.Commands.Enqueue(place); commander.Commands.Enqueue(right); commander.Commands.Enqueue(right); commander.Commands.Enqueue(move); commander.ExecuteCommands(); commander.UndoCommands(1); Assert.Equal(0, robot.Position.Y); Assert.Equal(0, robot.Position.X); }
public void Robot_TestMultipleMovementWithUndos_RobotReportsOrignalPosition() { Robot robot = new Robot(); Tabletop table = new Tabletop(5, 5); RobotCommander commander = new RobotCommander(); PlaceCommand place = new PlaceCommand(robot, table); place.Direction = "North"; MoveCommand move = new MoveCommand(robot, table); RightCommand right = new RightCommand(robot); LeftCommand left = new LeftCommand(robot); commander.Commands.Enqueue(place); commander.Commands.Enqueue(move); commander.Commands.Enqueue(move); commander.Commands.Enqueue(right); commander.Commands.Enqueue(move); commander.Commands.Enqueue(left); commander.Commands.Enqueue(left); commander.Commands.Enqueue(left); commander.Commands.Enqueue(move); commander.ExecuteCommands(); commander.UndoCommands(8); Assert.Equal(Facing.North, robot.Direction); Assert.Equal(0, robot.Position.Y); Assert.Equal(0, robot.Position.X); }