public void CreateCommandFactory_AddZeroInputCommands_InputsAreComplete() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("0"); commandFactory.AddInput("10 22"); //assert Assert.IsTrue(commandFactory.InputsAreComplete); }
public void CreateCommandFactory_TabSeparator_PositionIsCorrect() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("0"); commandFactory.AddInput("10\t22"); //assert Assert.AreEqual(10, commandFactory._commandSet.StartPosition.X); Assert.AreEqual(22, commandFactory._commandSet.StartPosition.Y); }
public void CreateCommandFactory_OneMovementCommandInput_CorrectNumberMovementCommandsAdded() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("3"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E 2"); //assert Assert.AreEqual(1, commandFactory._commandSet.MovementCommands.Count); }
public void CreateCommandFactory_TooManySteps_StepsShouldBe99999() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("1"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E 200000"); MovementCommand movementCommands = commandFactory._commandSet.MovementCommands[0]; //assert Assert.AreEqual(99999, movementCommands.MoveSteps); }
public void CreateCommandFactory_TooFewSteps_StepsShouldBe1() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("1"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E -3"); MovementCommand movementCommand = commandFactory._commandSet.MovementCommands[0]; //assert Assert.AreEqual(1, movementCommand.MoveSteps); }
public void CommandFactory_AddInCompleteInputs_NullCommandSet() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("5"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E -3"); CommandSet commandSet = commandFactory.GetCommandSet(); //assert Assert.IsNull(commandSet); }
public void CreateRobot_RobotCreated() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("0"); commandFactory.AddInput("0 0"); CommandSet commandSet = commandFactory.GetCommandSet(); //act Robot robot = new Robot(commandSet, null); //assert Assert.IsNotNull(robot); }
public void CommandFactory_AddInCompleteInputs_NullCommandSet() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("5"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E -3"); CommandSet commandSet = commandFactory.GetCommandSet(); //assert Assert.IsNull(commandSet); }
public void CreateRobot_RobotCreated() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("0"); commandFactory.AddInput("0 0"); CommandSet commandSet = commandFactory.GetCommandSet(); //act Robot robot = new Robot(commandSet, null); //assert Assert.IsNotNull(robot); }
public void CreateCommandFactory_AddThreeInputsCommands_InputsAreComplete() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("3"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E 2"); commandFactory.AddInput("N 1"); commandFactory.AddInput("S 1"); //assert Assert.IsTrue(commandFactory.InputsAreComplete); }
public void CreateCommandFactory_AddMinusInputCommands_InputsAreComplete() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("-3"); commandFactory.AddInput("10 22"); for (int i = 0; i < 10000; i++) { commandFactory.AddInput("E1"); } //assert Assert.IsTrue(commandFactory.InputsAreComplete); }
public void CreateCommandFactory_AddNegativeInputsCommands_InputsAreComplete() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("-1"); commandFactory.AddInput("10 22"); for (int i = 0; i < 10000; i++) { commandFactory.AddInput("N1"); } //assert Assert.IsTrue(commandFactory.InputsAreComplete); }
public void RunRobot_EmptyCommandSet_RobotPositionShouldNotChange() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("0"); commandFactory.AddInput("0 0"); CommandSet commandSet = commandFactory.GetCommandSet(); Robot robot = new Robot(commandSet, null); //act robot.ExecuteCommands(); //assert Assert.AreEqual(commandSet.StartPosition.X, robot.Position.X); Assert.AreEqual(commandSet.StartPosition.Y, robot.Position.Y); }
public void RunRobot_EmptyCommandSetNullReporter_ZeroPlaceReportGenerated() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("0"); commandFactory.AddInput("0 0"); CommandSet commandSet = commandFactory.GetCommandSet(); Robot robot = new Robot(commandSet, null); //act robot.ExecuteCommands(); string report = robot.PrintReport(); //assert Assert.AreEqual("=> Cleaned: unknown", report); }
public void CreateCommandFactory_AddTwentyThousandInputCommands_InputsAreComplete() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("11000"); commandFactory.AddInput("10 22"); for (int i = 0; i < 20000; i++) { commandFactory.AddInput("E1"); } //assert Assert.IsTrue(commandFactory.InputsAreComplete); }
public void RunRobot_EmptyCommandSet_RobotPositionShouldNotChange() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("0"); commandFactory.AddInput("0 0"); CommandSet commandSet = commandFactory.GetCommandSet(); Robot robot = new Robot(commandSet, null); //act robot.ExecuteCommands(); //assert Assert.AreEqual(commandSet.StartPosition.X, robot.Position.X); Assert.AreEqual(commandSet.StartPosition.Y, robot.Position.Y); }
public void RunRobot_EmptyCommandSetNullReporter_ZeroPlaceReportGenerated() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("0"); commandFactory.AddInput("0 0"); CommandSet commandSet = commandFactory.GetCommandSet(); Robot robot = new Robot(commandSet, null); //act robot.ExecuteCommands(); string report = robot.PrintReport(); //assert Assert.AreEqual("=> Cleaned: unknown", report); }
public void RunRobot_SimpleCommandSet_RobotPositionYShouldChangeBy1() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("1"); commandFactory.AddInput("0 0"); commandFactory.AddInput("N 1"); CommandSet commandSet = commandFactory.GetCommandSet(); Robot robot = new Robot(commandSet, null); //act robot.ExecuteCommands(); //assert Assert.AreEqual(commandSet.StartPosition.X, robot.Position.X); Assert.AreEqual(commandSet.StartPosition.Y + 1, robot.Position.Y); }
public void RunRobot_IllegalOutOfBoundsCommandSet_RobotPositionShouldRemainWithinBounds() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("1"); commandFactory.AddInput("100000 100000"); commandFactory.AddInput("N 1"); CommandSet commandSet = commandFactory.GetCommandSet(); Robot robot = new Robot(commandSet, null, null, new Location(100000, 100000)); //act robot.ExecuteCommands(); //assert Assert.AreEqual(commandSet.StartPosition.X, robot.Position.X); Assert.AreEqual(commandSet.StartPosition.Y, robot.Position.Y); }
public void RunRobot_SimplestCommandSetOneMove_RobotReports1LocationCleaned() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("1"); commandFactory.AddInput("10 10"); commandFactory.AddInput("N 1"); CommandSet commandSet = commandFactory.GetCommandSet(); IReport reporter = new SimpleReporter(); Robot robot = new Robot(commandSet, reporter, new Location(-100000, -100000), new Location(100000, 100000)); robot.ExecuteCommands(); //act string report = robot.PrintReport(); //assert Assert.AreEqual("=> Cleaned: 1", report); }
public void CommandFactory_Add5Command_NotNullCommandSetHas5Commands() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("5"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E -3"); commandFactory.AddInput("E -3"); commandFactory.AddInput("E -3"); commandFactory.AddInput("E -3"); commandFactory.AddInput("E -3"); CommandSet commandSet = commandFactory.GetCommandSet(); //assert Assert.AreEqual(5, commandSet.MovementCommands.Count); }
public void CommandFactory_Add5Command_NotNullCommandSetHas5Commands() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("5"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E -3"); commandFactory.AddInput("E -3"); commandFactory.AddInput("E -3"); commandFactory.AddInput("E -3"); commandFactory.AddInput("E -3"); CommandSet commandSet = commandFactory.GetCommandSet(); //assert Assert.AreEqual(5, commandSet.MovementCommands.Count); }
static void Main(string[] args) { //collect a set of inputs from standard in CommandFactory commandFactory = new CommandFactory(); while (!commandFactory.InputsAreComplete) { Console.WriteLine(">"); commandFactory.AddInput(Console.ReadLine()); } Console.WriteLine("Input complete. Press any key to continue.."); Console.ReadLine(); //robot should execute cleaning commands SimpleReporter reporter = new SimpleReporter(); Robot robbie = new Robot(commandFactory.GetCommandSet(), reporter, new Location(0,0), new Location(7,7)); robbie.ExecuteCommands(); //give output on the number of places cleaned Console.WriteLine(robbie.PrintReport()); }
static void Main(string[] args) { //collect a set of inputs from standard in CommandFactory commandFactory = new CommandFactory(); while (!commandFactory.InputsAreComplete) { Console.WriteLine(">"); commandFactory.AddInput(Console.ReadLine()); } Console.WriteLine("Input complete. Press any key to continue.."); Console.ReadLine(); //robot should execute cleaning commands SimpleReporter reporter = new SimpleReporter(); Robot robbie = new Robot(commandFactory.GetCommandSet(), reporter, new Location(0, 0), new Location(7, 7)); robbie.ExecuteCommands(); //give output on the number of places cleaned Console.WriteLine(robbie.PrintReport()); }
static void Main(string[] args) { //accept a set of input from standard in CommandFactory commandFactory = new CommandFactory(); while (!commandFactory.InputsAreComplete) { Console.WriteLine(">"); commandFactory.AddInput(Console.ReadLine()); } Console.WriteLine("Input is Complete. Press any key to continue"); Console.ReadLine(); //robot cleaner should execute cleaning commands SimpleReporter repoter = new SimpleReporter(); Robot vacuum = new Robot(commandFactory.GetCommandSet(), repoter, new Location(0, 0), new Location(7, 7)); vacuum.ExecuteCommands(); //robot cleaner should output the number of places cleaned Console.WriteLine(vacuum.PrintReport()); }
public void RunRobot_BoxMoveCommandSet_NumberofLocationsIsCorrect() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("4"); commandFactory.AddInput("0 0"); commandFactory.AddInput("N 7"); commandFactory.AddInput("E 7"); commandFactory.AddInput("S 7"); commandFactory.AddInput("W 7"); CommandSet commandSet = commandFactory.GetCommandSet(); IReport reporter = new SimpleReporter(); Robot robot = new Robot(commandSet, reporter, new Location(0, 0), new Location(7, 7)); //act robot.ExecuteCommands(); string report = robot.PrintReport(); //assert Assert.AreEqual("=> Cleaned: 28", report); }
public void RunRobot_BoxMoveCommandSet_NumberofLocationsIsCorrect() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("4"); commandFactory.AddInput("0 0"); commandFactory.AddInput("N 7"); commandFactory.AddInput("E 7"); commandFactory.AddInput("S 7"); commandFactory.AddInput("W 7"); CommandSet commandSet = commandFactory.GetCommandSet(); IReport reporter = new SimpleReporter(); Robot robot = new Robot(commandSet, reporter, new Location(0, 0), new Location(7, 7)); //act robot.ExecuteCommands(); string report = robot.PrintReport(); //assert Assert.AreEqual("=> Cleaned: 28", report); }
public void RunRobot_IllegalOutOfBoundsCommandSet_RobotPositionShouldRemainWithinBounds() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("1"); commandFactory.AddInput("100000 100000"); commandFactory.AddInput("N 1"); CommandSet commandSet = commandFactory.GetCommandSet(); Robot robot = new Robot(commandSet, null, null, new Location(100000, 100000) ); //act robot.ExecuteCommands(); //assert Assert.AreEqual(commandSet.StartPosition.X, robot.Position.X); Assert.AreEqual(commandSet.StartPosition.Y, robot.Position.Y); }
public void RunRobot_SimpleCommandSet_RobotPositionYShouldChangeBy1() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("1"); commandFactory.AddInput("0 0"); commandFactory.AddInput("N 1"); CommandSet commandSet = commandFactory.GetCommandSet(); Robot robot = new Robot(commandSet, null); //act robot.ExecuteCommands(); //assert Assert.AreEqual(commandSet.StartPosition.X, robot.Position.X); Assert.AreEqual(commandSet.StartPosition.Y + 1, robot.Position.Y); }
public void RunRobot_SimplestCommandSetOneMove_RobotReports1LocationCleaned() { //arrange CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInput("1"); commandFactory.AddInput("10 10"); commandFactory.AddInput("N 1"); CommandSet commandSet = commandFactory.GetCommandSet(); IReport reporter = new SimpleReporter(); Robot robot = new Robot(commandSet, reporter, new Location(-100000, -100000), new Location(100000, 100000)); robot.ExecuteCommands(); //act string report = robot.PrintReport(); //assert Assert.AreEqual("=> Cleaned: 1", report); }
public void CreateCommandFactory_OneMovementCommandInput_CorrectNumberMovementCommandsAdded() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("3"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E 2"); //assert Assert.AreEqual(1,commandFactory._commandSet.MovementCommands.Count); }
public void CreateCommandFactory_TabSeparator_PositionIsCorrect() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("0"); commandFactory.AddInput("10\t22"); //assert Assert.AreEqual(10, commandFactory._commandSet.StartPosition.X); Assert.AreEqual(22, commandFactory._commandSet.StartPosition.Y); }
public void CreateCommandFactory_AddZeroInputCommands_InputsAreComplete() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("0"); commandFactory.AddInput("10 22"); //assert Assert.IsTrue(commandFactory.InputsAreComplete); }
public void CreateCommandFactory_TooManySteps_StepsShouldBe99999() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("1"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E 200000"); MovementCommand movementCommand = commandFactory._commandSet.MovementCommands[0]; //assert Assert.AreEqual(99999, movementCommand.MoveSteps); }