예제 #1
0
 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);
 }
예제 #3
0
 public void TestPlatueSize()
 {
     Point coordinates = new Point(5, 5);
     Platue newPlatue = new Platue(coordinates);
     Assert.IsTrue(newPlatue.CoordPoints.x == 5 && newPlatue.CoordPoints.y == 5);
 }
예제 #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 InputParser(Platue platue, IRover rover, IEnumerable<char> instructionList)
 {
     m_platue = platue;
     m_rover = rover;
     m_instructionList = instructionList;
 }
예제 #6
0
 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>();
 }
예제 #7
0
 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;
 }