예제 #1
0
 public void TestCannotParseInvalidRoverPositionInput()
 {
     string roverPosition = "0 5 ES";
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParseMovementInstructions(roverPosition);
     bool expected = false;
     Assert.IsTrue(actual == expected, "Invalid rover position is parsed");
 }
예제 #2
0
 public void TestCannotParseInvalidMovementInstructionWithOtherCharactersInputData()
 {
     string instructions = "LMLRS";
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParseMovementInstructions(instructions);
     bool expected = false;
     Assert.IsTrue(expected == actual, "Wrong instruction input (contains invalid characters) is parsed!");
 }
예제 #3
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");
 }
예제 #4
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");
 }
예제 #5
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");
 }
예제 #6
0
 public void TestCannotParseEmptyMovementInstruction()
 {
     string instruction = String.Empty;
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParseMovementInstructions(instruction);
     bool expected = false;
     Assert.IsTrue(expected == actual, "Empty rover movement instructions string is parsed");
 }
예제 #7
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);
            }
        }
예제 #8
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");
 }
예제 #9
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");
 }
예제 #10
0
 public void TestParsedMovementInstructionCharacterListIsValid()
 {
     string instructions = "LMLR";
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParseMovementInstructions(instructions);
     bool expected = true;
     IEnumerable<char> expectedList = new List<char>() {'L', 'M', 'L', 'R'};
     if (expectedList.Count() != inputParser.MovementInstructions.Count())
     {
         actual = false;
     }
       for (int i = 0; i < expectedList.Count(); i++)
     {
         if (expectedList.ElementAt(i) != inputParser.MovementInstructions.ElementAt(i))
             actual = false;
     }
     Assert.IsTrue(expected==actual, "Movement instruction string is parsed wrongly, characters are not matched");
 }
예제 #11
0
 public void TestCanParseInstructionStringOfRover()
 {
     string instruction = "LMLMLLL";
     IInputParser inputParser=new InputParser();
     bool actual=inputParser.ParseMovementInstructions(instruction);
     bool expected = true;
     Assert.IsTrue(expected == actual, "Valid movement instructions string cannot be parsed");
 }
예제 #12
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");
 }
예제 #13
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");
 }
예제 #14
0
 public void TestCannotParseWhiteSpaceMovementInstruction()
 {
     string instruction = " ";
     IInputParser inputParser = new InputParser();
     bool actual = inputParser.ParseMovementInstructions(instruction);
     bool expected = false;
     Assert.IsTrue(expected == actual, "WhiteSpace rover movement instructions string is parsed");
 }