Example #1
0
        public void Move_Rover_Outside_Plateau_Boundaries()
        {
            //Arrange  (Setup the rover)
            SetupRover();

            //Act (Process command)
            _rover.Process("MMRRMMRRRMRRMMMMRRRM");

            //Assert
            Console.WriteLine(_rover.PrintRoverPosition());
            Assert.IsTrue(_rover.PrintRoverPosition().Contains("Rover outside the plateau"));
        }
Example #2
0
        public void Move_Rover_Outside_Borders()
        {
            //Arrange
            SetupRoverOne();

            //Act
            _roverOne.Process("MMRMMRMRRMMRRMRMRMMMMMMRMMMM");

            //Assert
            string result = _roverOne.ToString();

            Console.WriteLine(result);
            Assert.IsTrue(result.Contains("Rover outside the plateau"));
        }
Example #3
0
        public void Move_RoverThree_OutsideBordersWithNotAllow()
        {
            //Arrange //Act
            SetupRoverThree(null);

            //Act
            Assert.Throws <System.InvalidOperationException>(() => _roverThree.Process("MRM"));

            //Assert - RoverThree has not moved
            string result = _roverThree.ToString();

            Console.WriteLine(result);
            Assert.AreEqual(result, "0 0 W");
        }
Example #4
0
        public void Run()
        {
            try
            {
                string anotherRover;
                Console.WriteLine("Enter the size of the Plateau:");
                string plateau            = Console.ReadLine();
                var    plateauCoordinates = plateau != null?plateau.Split(' ').ToArray() : null;

                _rover.RoverPlateau.XMax = plateauCoordinates != null?int.Parse(plateauCoordinates[0]) : 0;

                _rover.RoverPlateau.YMax = plateauCoordinates != null?int.Parse(plateauCoordinates[1]) : 0;

                do
                {
                    Console.WriteLine("Enter the inputs for Rover Position and direction:");
                    var position = Console.ReadLine();
                    _rover.SetPosition(position);

                    Console.WriteLine("Enter the Rover commands:");
                    string commands = Console.ReadLine();
                    _rover.Process(commands);
                    Console.WriteLine(_rover.RoverPosition.X.ToString() + ' ' + _rover.RoverPosition.Y.ToString() + ' ' + _rover.RoverOrientation.ToString());
                    Console.WriteLine("Do you want to deploy another Rover? (Y/N)");
                    anotherRover = Console.ReadLine();
                } while (anotherRover.ToLower() == "y");
            }
            catch
            {
                //to do - log the exception
                Console.WriteLine("Invalid Input. Please enter the coordinates seperated by space");
            }
        }
Example #5
0
        public void Process()
        {
            notifier.OutputLine("Input");
            if (rovers != null && rovers.Length > 0)
            {
                notifier.OutputLine("{0} {1}", rovers[0].Plateau.Boundary.X, rovers[0].Plateau.Boundary.Y);

                for (int i = 0; i < rovers.Length; i++)
                {
                    //Display Input
                    notifier.OutputLine(rovers[i].ToString());
                    notifier.OutputLine(moves[i]);
                }
                notifier.OutputLine();
                //Process and Display Output
                notifier.OutputLine("Output");
                for (int i = 0; i < rovers.Length; i++)
                {
                    IRover rover = rovers[i];
                    rover.Process(moves[i]);
                    notifier.OutputLine(rover.ToString());
                }
            }
            else
            {
                notifier.OutputLine("No rovers!");
            }
        }
        public RoverViewModel Move([FromBody] RoverModel model)
        {
            if (_roverCaching.IsItemExists(model.Id))
            {
                var result = _rover.Process(Get(model.Id), model.MovementInstruction);
                _roverCaching.Remove(model.Id);
                _roverCaching.SetItem(model.Id, result);
            }

            return(Get(model.Id));
        }
Example #7
0
        public void ProcessTest()
        {
            _rover.RoverPosition   = new Position();
            _rover.RoverPosition.X = 1;
            _rover.RoverPosition.Y = 2;
            string command = "LMLMLMLMM";

            _rover.Process(command);
            Assert.IsNotNull(_rover.RoverPosition);
            Assert.IsNotNull(_rover.RoverOrientation);
            Assert.AreEqual(_rover.RoverPosition.X, 1);
            Assert.AreEqual(_rover.RoverPosition.Y, 3);
            Assert.AreEqual(_rover.RoverOrientation.ToString(), "N");
        }
Example #8
0
        public void Move_RoverTwo_Check_Output()
        {
            //Arrange
            SetupRoverTwo();

            //Act
            _roverTwo.Process("MMRMMRMRRM");

            //Assert
            string result = _roverTwo.ToString();

            Console.WriteLine(result);
            Assert.AreEqual(result, "5 1 E");
        }