예제 #1
0
 public void TestCannotParseInvalidPlatueInput()
 {
     string platueInput = "0 R R";
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParsePlatueInput(platueInput);
     bool expected = false;
     Assert.IsTrue(actual==expected, "Invalid platue size input is parsed");
 }
예제 #2
0
 public void TestCannotParseEmptyPlatueSize()
 {
     string platueSize = String.Empty;
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParsePlatueInput(platueSize);
     bool expected = false;
     Assert.IsTrue(expected == actual, "Empty platue size string is parsed");
 }
예제 #3
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);
            }
        }
예제 #4
0
 public void TestParsedPlatueSizeIsValid()
 {
     string platueSize = "5 5";
     IInputParser inputParser = new InputParser();
     inputParser.ParsePlatueInput(platueSize);
     Platue actualPlatue = inputParser.Platue;
     Point expectedPoint= new Point(5,5);
     Platue expectedPlatue = new Platue(expectedPoint);
     Assert.IsTrue(expectedPlatue.CoordPoints.x == actualPlatue.CoordPoints.x && expectedPlatue.CoordPoints.y == actualPlatue.CoordPoints.y, "Valid Platue size cannot be parsed");
 }
예제 #5
0
 public void TestCannotParseWhiteSpacePlatueSize()
 {
     string platueSize =" ";
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParsePlatueInput(platueSize);
     bool expected = false;
     Assert.IsTrue(expected == actual, "WhiteSpace platue size string is parsed");
 }