Пример #1
0
        public void RoverMovesForwardsAndOrBackwards(Int32 expectedYCoordinate, params Char[] commands)
        {
            marsRover.RunRoverWithCommands(commands);
            var roverYCoordinate = marsRover.YCoordinate;

            Assert.That(expectedYCoordinate, Is.EqualTo(roverYCoordinate));
        }
Пример #2
0
        public void RoverTurning(Char initialDirection, String commands, Char endingDireciton)
        {
            var rover = new MarsRover(InitialXCoordinate, InitialYCoordinate, initialDirection);

            rover.RunRoverWithCommands(commands);
            Assert.That(rover.roverState.Direction, Is.EqualTo(endingDireciton));
        }
Пример #3
0
        public void RoverUnitVectors(Char initialDirection, String commands, Int32 endingXCoordinate, Int32 endingYCoordinate)
        {
            var rover = new MarsRover(InitialXCoordinate, InitialYCoordinate, initialDirection);

            rover.RunRoverWithCommands(commands);
            Assert.That(rover.XCoordinate, Is.EqualTo(endingXCoordinate));
            Assert.That(rover.YCoordinate, Is.EqualTo(endingYCoordinate));
        }
Пример #4
0
        public void RoverFullMovement(Char initialDirection, Int32 initialXCoordinate, Int32 initialYCoordinate, String commands, Char endingDireciton, Int32 endingXCoordinate, Int32 endingYCoordinate)
        {
            var rover = new MarsRover(initialXCoordinate, initialYCoordinate, initialDirection);

            rover.RunRoverWithCommands(commands);
            Assert.That(rover.roverState.Direction, Is.EqualTo(endingDireciton));
            Assert.That(rover.XCoordinate, Is.EqualTo(endingXCoordinate));
            Assert.That(rover.YCoordinate, Is.EqualTo(endingYCoordinate));
        }
Пример #5
0
        public void VerifyRoverWrapsFromLeftOfGridToRight()
        {
            marsRover = new MarsRover(grid, 0, 0, DirectionConstants.West);
            marsRover.RunRoverWithCommands("f");
            Assert.AreEqual(4, marsRover.XCoordinate);
            Assert.AreEqual(0, marsRover.YCoordinate);

            var stringGrid = marsRover.PrintMap();

            System.Diagnostics.Debug.WriteLine(stringGrid);
        }
Пример #6
0
        public void VerifyRoverWrapsFromTopOfGridToTheBottom()
        {
            marsRover = new MarsRover(grid, 2, 4, DirectionConstants.North);
            marsRover.RunRoverWithCommands("f");
            Assert.AreEqual(2, marsRover.XCoordinate);
            Assert.AreEqual(0, marsRover.YCoordinate);

            var stringGrid = marsRover.PrintMap();

            System.Diagnostics.Debug.WriteLine(stringGrid);
        }
Пример #7
0
        public void GridToStringWorks()
        {
            grid.PlaceObstacleAt(4, 4);
            grid.PlaceObstacleAt(0, 0);
            marsRover = new MarsRover(grid, 0, 4, DirectionConstants.East);
            marsRover.RunRoverWithCommands("f");
            var stringGrid = marsRover.PrintMap();

            System.Diagnostics.Debug.WriteLine(stringGrid);
            Assert.AreEqual(".R__X\n_____\n_____\n_____\nX____\n", stringGrid);
        }
Пример #8
0
        public void RoverStopsAtObstacleInMultiStepPath()
        {
            grid.PlaceObstacleAt(4, 4);
            marsRover = new MarsRover(grid, 0, 0, DirectionConstants.East);
            marsRover.RunRoverWithCommands("fflffrflffrf");
            Assert.IsTrue(marsRover.AtObstacle);

            var stringGrid = marsRover.PrintMap();

            System.Diagnostics.Debug.WriteLine(stringGrid);
        }
Пример #9
0
        public void RoverStopsAtObstacleInPath(Char initialDirection)
        {
            grid.PlaceObstacleAt(1, 0);
            grid.PlaceObstacleAt(2, 1);
            grid.PlaceObstacleAt(0, 1);
            grid.PlaceObstacleAt(1, 2);
            marsRover = new MarsRover(grid, 1, 1, initialDirection);
            marsRover.RunRoverWithCommands("f");
            Assert.IsTrue(marsRover.AtObstacle);

            var stringGrid = marsRover.PrintMap();

            System.Diagnostics.Debug.WriteLine(stringGrid);
        }
Пример #10
0
 public void RoverDoesntRunInvalidInput()
 {
     marsRover.RunRoverWithCommands("༼ つ ͡◕ Ѿ ͡◕ ༽つ");
     Assert.That(InitialYCoordinate, Is.EqualTo(marsRover.YCoordinate));
 }