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"); }
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!"); }
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"); }
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"); }
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"); }
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"); }
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); } }
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"); }
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"); }
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"); }
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"); }
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"); }
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"); }
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"); }