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