public RoverBusinessLogic(IInputParser inputParser) { this.m_inputParser = inputParser; this.m_Rover = inputParser.Rover; this.m_nasaPlatue = inputParser.Platue; this.m_instructionList = inputParser.MovementInstructions; }
public void TestProcessRoverMovementInstructionsRoverMovesTwoMs() { Platue currentPlatue=new Platue(new Point(10,10)); IRover currentRover=new Rover(new Point(0,0), CardinalCompassPoints.N ); IEnumerable<char> instructions = new List<char>() {'M', 'M'}; IRoverBusinessLogic businessLogic = new RoverBusinessLogic(new InputParser(currentPlatue, currentRover, instructions)); string actualNewPosition=businessLogic.ProcessRoverMovementInstructions(); string expectedRoverPosition = "0 2 N"; Assert.IsTrue(expectedRoverPosition==actualNewPosition); }
public void TestPlatueSize() { Point coordinates = new Point(5, 5); Platue newPlatue = new Platue(coordinates); Assert.IsTrue(newPlatue.CoordPoints.x == 5 && newPlatue.CoordPoints.y == 5); }
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 InputParser(Platue platue, IRover rover, IEnumerable<char> instructionList) { m_platue = platue; m_rover = rover; m_instructionList = instructionList; }
public InputParser() { m_rover = new Rover(new Point(0, 0), CardinalCompassPoints.Wrong); m_platue = new Platue(new Point(0, 0)); m_instructionList=new List<char>(); }
bool IInputParser.ParsePlatueInput(string platueSize) { if (CheckInputIsNullOrWhiteSpaceOrEmpty(platueSize)) return false; if (!Regex.IsMatch(platueSize, @"[0-9]{1} [0-9]{1}")) return false; string[] inputs = platueSize.Split(' '); if (inputs.Length == 2) { int xcoord = Convert.ToInt32(inputs[0]); int ycoord = Convert.ToInt32(inputs[1]); m_platue=new Platue(new Point(xcoord, ycoord)); return true; } return false; }