public void CreateCommandFactory_AddZeroInputCommands()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("0");
            commandFactory.AddInputs("10 22");

            Assert.IsTrue(commandFactory.IsInputComplete);
        }
        public void CreateCommandFactory_SingleMoveCommand()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("2");
            commandFactory.AddInputs("10 22");
            commandFactory.AddInputs("E 2");

            Assert.AreEqual(1, commandFactory.commandSet.MoveCommands.Count);
        }
        public void CreateCommandFactory_NormalPosition()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("0");
            commandFactory.AddInputs("10 22");

            Assert.AreEqual(10, commandFactory.commandSet.StartPosition.X);
            Assert.AreEqual(22, commandFactory.commandSet.StartPosition.Y);
        }
        public void CreateCommandFactory_SingleMoveCommandWithLessSteps()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("2");
            commandFactory.AddInputs("10 22");
            commandFactory.AddInputs("E -1");
            MoveCommand moveCommand = commandFactory.commandSet.MoveCommands[0];

            Assert.AreEqual(1, moveCommand.MoveSteps);
        }
        public void CreateCommandFactory_AddNegativeInputCommands()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("-1");
            commandFactory.AddInputs("10 22");

            commandFactory.AddInputs("N 1");

            Assert.IsTrue(commandFactory.IsInputComplete);
        }
        public void CreateCommandFactory_AddThreeInputcommands()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("3");
            commandFactory.AddInputs("10 22");
            commandFactory.AddInputs("E 2");
            commandFactory.AddInputs("N 1");
            commandFactory.AddInputs("S 2");

            Assert.IsTrue(commandFactory.IsInputComplete);
        }
        public void CommandFactory_NullCommandSet()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("3");
            commandFactory.AddInputs("10 22");
            commandFactory.AddInputs("E -1");

            CommandSet commandSet = commandFactory.GetCommandSet();

            Assert.IsNull(commandSet);
        }
Example #8
0
        public void CreateRobot_RoboCreation()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("0");
            commandFactory.AddInputs("0 0");

            CommandSet commandSet = commandFactory.GetCommandSet();

            Robot robot = new Robot(commandSet, null);

            Assert.IsNotNull(robot);
        }
        public void CreateCommandFactory_AddTwentyThousandInputCommands()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("12000");
            commandFactory.AddInputs("10 22");

            for (int i = 0; i < 20000; i++)
            {
                commandFactory.AddInputs("N 1");
            }

            Assert.IsTrue(commandFactory.IsInputComplete);
        }
Example #10
0
        public void RunRobot_EmptyCommandSetWithNullReport()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("0");
            commandFactory.AddInputs("0 0");

            CommandSet commandSet = commandFactory.GetCommandSet();
            Robot      robot      = new Robot(commandSet, null);

            robot.ExecuteCommands();
            string report = robot.ReportOutPut();

            Assert.AreEqual("=> Cleaned: unknown", report);
        }
Example #11
0
        public void RunRobot_WithNoPositionChange()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("0");
            commandFactory.AddInputs("0 0");

            CommandSet commandSet = commandFactory.GetCommandSet();
            Robot      robot      = new Robot(commandSet, null);

            robot.ExecuteCommands();

            Assert.AreEqual(commandSet.StartPosition.X, robot.Position.X);
            Assert.AreEqual(commandSet.StartPosition.Y, robot.Position.Y);
        }
Example #12
0
        static void Main(string[] args)
        {
            //Get input commands
            CommandFactory commandFactory = new CommandFactory();

            Console.WriteLine("Enter Inputs:");

            while (!commandFactory.IsInputComplete)
            {
                Console.WriteLine(">");
                commandFactory.AddInputs(Console.ReadLine());
            }
            Console.WriteLine("Input Complete, Press any key to continue..");
            Console.ReadLine();

            //Execute commands
            SimpleReporter reporter = new SimpleReporter();
            Robot          robo     = new Robot(commandFactory.GetCommandSet(), reporter, new Location(0, 0), new Location(10, 10));

            robo.ExecuteCommands();

            //Reports number of places cleaned
            Console.WriteLine(reporter.ReportOutPut());

            Console.ReadLine();
        }
Example #13
0
        public void RunRobot_OutofBoundsCommandSetWithMovements()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("1");
            commandFactory.AddInputs("100000 100000");
            commandFactory.AddInputs("N 1");

            CommandSet commandSet = commandFactory.GetCommandSet();
            Robot      robot      = new Robot(commandSet, null, null, new Location(100000, 100000));

            robot.ExecuteCommands();

            Assert.AreEqual(commandSet.StartPosition.X, robot.Position.X);
            Assert.AreEqual(commandSet.StartPosition.Y, robot.Position.Y);
        }
Example #14
0
        public void RunRobot_SimpleCommandSetWithMovementBy1()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("1");
            commandFactory.AddInputs("0 0");
            commandFactory.AddInputs("N 1");

            CommandSet commandSet = commandFactory.GetCommandSet();
            Robot      robot      = new Robot(commandSet, null);

            robot.ExecuteCommands();

            Assert.AreEqual(commandSet.StartPosition.X, robot.Position.X);
            Assert.AreEqual(commandSet.StartPosition.Y + 1, robot.Position.Y);
        }
Example #15
0
        public void RunRobot_ZeroPlaceCleanReport()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("0");
            commandFactory.AddInputs("0 0");

            IReport reporter = new TestReporter();

            CommandSet commandSet = commandFactory.GetCommandSet();
            Robot      robot      = new Robot(commandSet, reporter);

            robot.ExecuteCommands();
            string report = robot.ReportOutPut();

            Assert.AreEqual("=> Cleaned: 0", report);
        }
Example #16
0
        public void RunRobot_SimpleCommandSetReportLocationCleaned()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("1");
            commandFactory.AddInputs("20 20");
            commandFactory.AddInputs("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();

            string report = robot.ReportOutPut();

            Assert.AreEqual("=> Cleaned: 1", report);
        }
        public void CommandFactory_4CommandSet()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("4");
            commandFactory.AddInputs("10 22");
            commandFactory.AddInputs("E -1");
            commandFactory.AddInputs("E -1");
            commandFactory.AddInputs("E -1");
            commandFactory.AddInputs("E -1");

            CommandSet commandSet = commandFactory.GetCommandSet();

            Assert.AreEqual(4, commandSet.MoveCommands.Count);
        }
Example #18
0
        public void RunRobot_CommandSetWithLocationMovements()
        {
            CommandFactory commandFactory = new CommandFactory();

            commandFactory.AddInputs("4");
            commandFactory.AddInputs("0 0");
            commandFactory.AddInputs("N 5");
            commandFactory.AddInputs("E 5");
            commandFactory.AddInputs("S 5");
            commandFactory.AddInputs("W 5");

            CommandSet commandSet = commandFactory.GetCommandSet();

            IReport reporter = new SimpleReporter();

            Robot robot = new Robot(commandSet, reporter, new Location(0, 0), new Location(5, 5));

            robot.ExecuteCommands();

            string report = robot.ReportOutPut();

            Assert.AreEqual("=> Cleaned: 20", report);
        }