Example #1
0
        public void Robot_NumberOfInstructions_Less_Than_Zero()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("-1");
            robotInstructions.GetInputInstructions("10 2");

            Assert.AreEqual(0, robotInstructions._numbersOfInstructions);
        }
Example #2
0
        public void Robot_NumberOfInstructions_Greater_Than_10000()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("15000");
            robotInstructions.GetInputInstructions("10 2");

            Assert.AreEqual(10000, robotInstructions._numbersOfInstructions);
        }
Example #3
0
        public void Robot_With_Incomplete_Input()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("10");
            robotInstructions.GetInputInstructions("10 2");
            robotInstructions.GetInputInstructions("E 0");
            Assert.IsFalse(robotInstructions.InputsAreComplete);
        }
Example #4
0
        public void Robot_InputPosition()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("1");
            robotInstructions.GetInputInstructions("10 2");

            Assert.AreEqual(10, robotInstructions._position.X);
            Assert.AreEqual(2, robotInstructions._position.Y);
        }
Example #5
0
        public void Robot_One_Movement_Instruction()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("1");
            robotInstructions.GetInputInstructions("10 2");
            robotInstructions.GetInputInstructions("E 2");

            Assert.AreEqual(1, robotInstructions._movementInstruction.Count);
        }
        public void CreateRobot()
        {
            RobotInstructions commands = new RobotInstructions();

            commands.GetInputInstructions("0");
            commands.GetInputInstructions("0 0");
            Robot robot = new Robot(commands);

            Assert.IsNotNull(robot);
        }
Example #7
0
        public void Robot_Movement_With_Morethan99999_Steps()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("1");
            robotInstructions.GetInputInstructions("10 2");
            robotInstructions.GetInputInstructions("E 1500000");
            MovementInstruction moveCommand = robotInstructions._movementInstruction[0];

            Assert.AreEqual(99999, moveCommand.StepstoMove);
        }
Example #8
0
        public void Robot_Movement_With_Zero_Step()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("1");
            robotInstructions.GetInputInstructions("10 2");
            robotInstructions.GetInputInstructions("E 1");
            MovementInstruction moveCommand = robotInstructions._movementInstruction[0];

            Assert.AreEqual(1, moveCommand.StepstoMove);
        }
Example #9
0
        public void Robot_With_Complete_Input()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("3");
            robotInstructions.GetInputInstructions("10 2");
            robotInstructions.GetInputInstructions("E 1");
            robotInstructions.GetInputInstructions("E 1");
            robotInstructions.GetInputInstructions("E 1");
            Assert.IsTrue(robotInstructions.InputsAreComplete);
        }
        public void Robot_WithZeroCommand()
        {
            RobotInstructions commands = new RobotInstructions();

            commands.GetInputInstructions("0");
            commands.GetInputInstructions("6 8");
            Robot robot = new Robot(commands);

            robot.FollowInstructions();
            Assert.AreEqual(commands._position.X, robot._position.X);
            Assert.AreEqual(commands._position.Y, robot._position.Y);
        }
        public void MoveRobot_With_OutOfRangeCoordinates()
        {
            RobotInstructions commands = new RobotInstructions();

            commands.GetInputInstructions("1");
            commands.GetInputInstructions("-100000 200000");
            commands.GetInputInstructions("E 1");
            Robot robot = new Robot(commands);

            robot.FollowInstructions();
            Assert.IsTrue(robot._position.ValidateInPlan(robot._position));
        }
        public void Robot_WithOnePlaceCleaned()
        {
            RobotInstructions commands = new RobotInstructions();

            commands.GetInputInstructions("0");
            commands.GetInputInstructions("6 8");
            Robot robot = new Robot(commands);

            robot.FollowInstructions();
            string output = robot.PrintCleanedPlaces();

            Assert.AreEqual("=> Cleaned: 1", output);
        }
Example #13
0
        public void Get_Ten_Thousand_InputCommands()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("10000");
            robotInstructions.GetInputInstructions("10 2");
            for (int i = 0; i < 10000; i++)
            {
                robotInstructions.GetInputInstructions("N 2");
            }

            Assert.IsTrue(robotInstructions.InputsAreComplete);
        }
        public void MoveRobot_WithOneCommand()
        {
            RobotInstructions commands = new RobotInstructions();

            commands.GetInputInstructions("1");
            commands.GetInputInstructions("6 8");
            commands.GetInputInstructions("E 1");
            Robot robot = new Robot(commands);

            robot.FollowInstructions();
            Assert.AreEqual(commands._position.X + 1, robot._position.X);
            Assert.AreEqual(commands._position.Y, robot._position.Y);
        }
        public void Robot_Will_Not_Move_More_Than_999999_Steps()
        {
            RobotInstructions commands = new RobotInstructions();

            commands.GetInputInstructions("1");
            commands.GetInputInstructions("0 0");
            commands.GetInputInstructions("N 100000");
            Robot robot = new Robot(commands);

            robot.FollowInstructions();
            //Robot will move towards North, i.e Y++
            Assert.AreEqual(99999, robot._position.Y);
        }
        public void Robot_Will_Never_Go_OutSide_Of_GridRange()
        {
            RobotInstructions commands = new RobotInstructions();

            commands.GetInputInstructions("1");
            commands.GetInputInstructions("-100000 100000");
            commands.GetInputInstructions("W 1");
            Robot robot = new Robot(commands);

            robot.FollowInstructions();
            Assert.AreEqual(commands._position.X, robot._position.X);
            Assert.AreEqual(commands._position.Y, robot._position.Y);
        }
        public void MoveRobot_InSideTheBounds()
        {
            RobotInstructions commands = new RobotInstructions();

            commands.GetInputInstructions("1");
            commands.GetInputInstructions("-6 8");
            commands.GetInputInstructions("W 1");
            Robot robot = new Robot(commands);

            robot.FollowInstructions();
            //Robot will move one position towards West
            Assert.AreEqual(commands._position.X - 1, robot._position.X);
            Assert.AreEqual(commands._position.Y, robot._position.Y);
        }
Example #18
0
        public void Robot_With_Five_Complete_Commands()
        {
            RobotInstructions robotInstructions = new RobotInstructions();

            robotInstructions.GetInputInstructions("5");
            robotInstructions.GetInputInstructions("10 2");
            robotInstructions.GetInputInstructions("E 3");
            robotInstructions.GetInputInstructions("E 3");
            robotInstructions.GetInputInstructions("E 3");
            robotInstructions.GetInputInstructions("E 3");
            robotInstructions.GetInputInstructions("E 3");
            Assert.AreEqual(5, robotInstructions._numbersOfInstructions);
        }
Example #19
0
        static void Main(string[] args)
        {
            RobotInstructions instructions = new RobotInstructions();

            while (!instructions.InputsAreComplete)
            {
                instructions.GetInputInstructions(Console.ReadLine());
            }

            Robot robot = new Robot(instructions);

            robot.FollowInstructions();

            Console.WriteLine(robot.PrintCleanedPlaces());


            Console.ReadLine();
        }
        public void MoveRobot_In_All_Directions()
        {
            RobotInstructions commands = new RobotInstructions();

            commands.GetInputInstructions("4");
            commands.GetInputInstructions("0 0");
            commands.GetInputInstructions("N 5");
            commands.GetInputInstructions("E 5");
            commands.GetInputInstructions("S 5");
            commands.GetInputInstructions("W 5");

            Robot robot = new Robot(commands);

            robot.FollowInstructions();
            string output = robot.PrintCleanedPlaces();

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