Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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);
        }