Ejemplo n.º 1
0
 public void TestCannotParseEmptyRoverPosition()
 {
     string roverPosition = String.Empty;
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParseInputRoverPosition(roverPosition);
     bool expected = false;
     Assert.IsTrue(expected == actual, "Empty rover position string is parsed");
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter Platue size input:"); // Prompt
            string platueSize = Console.ReadLine();
            IInputParser inputParser=new InputParser();
            bool successful = inputParser.ParsePlatueInput(platueSize);
            while ( !successful)
            {
                Console.WriteLine("The platue size is invalid. Please enter Platue size input:"); // Prompt
                platueSize = Console.ReadLine();
                successful = inputParser.ParsePlatueInput(platueSize);
            }

            while (true)
            {
                Console.WriteLine("Enter Position of Rover input:"); // Prompt
                string positionOfRover = Console.ReadLine();
                successful = inputParser.ParseInputRoverPosition(positionOfRover);
                while (!successful)
                {
                    Console.WriteLine("The position of rover is invalid. Please enter again:"); // Prompt
                    positionOfRover = Console.ReadLine();
                    successful = inputParser.ParseInputRoverPosition(positionOfRover);
                }
                Console.WriteLine("Enter movement instructions for the rover:"); // Prompt
                string roverMovementInstructions = Console.ReadLine();
                successful = inputParser.ParseMovementInstructions(roverMovementInstructions);
                while (!successful)
                {
                    Console.WriteLine("Enter movement instructions for the rover:"); // Prompt
                    roverMovementInstructions = Console.ReadLine();
                    successful = inputParser.ParseMovementInstructions(roverMovementInstructions);
                }
                IRoverBusinessLogic myRoverBusinessLogic = new RoverBusinessLogic(inputParser);
                string roversNewPosition = myRoverBusinessLogic.ProcessRoverMovementInstructions();
                Console.WriteLine("The new position of the rover is "+roversNewPosition);
            }
        }
Ejemplo n.º 3
0
 public void TestParsedRoverPositionInputDataIsValid()
 {
     string roverPosition = "0 0 N";
     IInputParser inputParser = new InputParser();
     inputParser.ParseInputRoverPosition(roverPosition);
     IRover actualRover = inputParser.Rover;
     IRover expectedRover = new Rover(new Point(0,0), CardinalCompassPoints.N);
     Assert.IsTrue(expectedRover.Coordinates.x == actualRover.Coordinates.x && expectedRover.Coordinates.y == actualRover.Coordinates.y && expectedRover.Orientation== actualRover.Orientation, "Valid rover's position data cannot be parsed");
 }
Ejemplo n.º 4
0
 public void TestCannotParseWhiteSpaceRoverPosition()
 {
     string roverPosition = " ";
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParseInputRoverPosition(roverPosition);
     bool expected = false;
     Assert.IsTrue(expected == actual, "WhiteSpace rover position string is parsed");
 }