public void MarsServiceTest_MoveRover_Start_ObstacleDetected_ExpectedException()
        {
            IWorld world       = WorldBuilder.Get4x4WorldWithObstacles();
            var    marsService = Substitute.For <MarsService>(world);

            marsService.LandRover(0, 0, DirectionEnum.East);

            string[] commands = { "F", "L", "F" };

            Position position = marsService.MoveRover(commands);
        }
Exemple #2
0
        public void MarsRoverTest_MoveLeft_ObstacleEncountred()
        {
            IWorld world = WorldBuilder.Get4x4WorldWithObstacles();

            Rover rover = new RoverBuilder()
                          .WithWorld(world)
                          .WithInitialDirectionNorth()
                          .WithInitialPosition(2, 2)
                          .Build();

            rover.MoveLeft();
        }
        public void MarsServiceTest_MoveRover_ObstacleDetected_LastPosition11N()
        {
            IWorld world       = WorldBuilder.Get4x4WorldWithObstacles();
            var    marsService = Substitute.For <MarsService>(world);

            marsService.LandRover(0, 0, DirectionEnum.East);

            string[] commands = { "F", "L", "F" };

            Position lastPosition = null;

            try
            {
                Position position = marsService.MoveRover(commands);
            }
            catch (RoverException ex)
            {
                lastPosition = ex.LastPosition;
            }

            Assert.AreEqual(1, lastPosition.X);
            Assert.AreEqual(1, lastPosition.Y);
            Assert.AreEqual(DirectionEnum.North, lastPosition.Direction);
        }