Пример #1
0
        public void MarsRoverTest_MoveLeft_ObstacleEncountred()
        {
            IWorld world = WorldBuilder.Get4x4WorldWithObstacles();

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

            rover.MoveLeft();
        }
Пример #2
0
        public void MarsRoverTest_RightEdgeDirNorth_MoveRight_RoverStepInLeftEdge()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

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

            rover.MoveRight();
            Assert.AreEqual(world.GetLeftEdgeXCoordinates(), rover.Position.X);
        }
Пример #3
0
        public void MarsRoverTest_TopEdgeDirWest_MoveRight_RoverStepInBottomEdge()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

            Rover rover = new RoverBuilder()
                          .WithWorld(world)
                          .WithInitialDirectionWest()
                          .WithInitialPosition(0, world.GetTopEdgeYCoordinates())
                          .Build();

            rover.MoveRight();
            Assert.AreEqual(world.GetBottomEdgeYCoordinates(), rover.Position.Y);
        }
Пример #4
0
        public void MarsRoverTest_InitialPosition00N_MoveForward_FinalPosition01N()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

            Rover rover = new RoverBuilder()
                          .WithWorld(world)
                          .WithInitialStateLeftBottomNorth()
                          .Build();

            rover.MoveForward();

            Assert.AreEqual(rover.Position.X, 0);
            Assert.AreEqual(rover.Position.Y, 1);
            Assert.AreEqual(rover.Position.Direction, DirectionEnum.North);
        }
Пример #5
0
        public void MarsRoverTest_InitialPosition00E_MoveForward_FinalPosition10E()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

            Rover rover = new RoverBuilder()
                          .WithWorld(world)
                          .WithInitialStateLeftBottomEast()
                          .Build();

            rover.MoveForward();

            Assert.AreEqual(1, rover.Position.X);
            Assert.AreEqual(0, rover.Position.Y);
            Assert.AreEqual(DirectionEnum.East, rover.Position.Direction);
        }
Пример #6
0
        public void MarsRoverTest_InitialPosition22S_MoveForward_FinalPosition21S()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

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

            rover.MoveForward();

            Assert.AreEqual(rover.Position.X, 2);
            Assert.AreEqual(rover.Position.Y, 1);
            Assert.AreEqual(rover.Position.Direction, DirectionEnum.South);
        }
Пример #7
0
        public void MarsRoverTest_InitialiPosition22South_MoveRight_FinalPosition12W()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

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

            rover.MoveRight();

            Assert.AreEqual(1, rover.Position.X);
            Assert.AreEqual(2, rover.Position.Y);
            Assert.AreEqual(DirectionEnum.West, rover.Position.Direction);
        }
Пример #8
0
        public void MarsRoverTest_InitialPosition22E_MoveLeft_FinalPosition23N()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

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

            rover.MoveLeft();

            Assert.AreEqual(rover.Position.X, 2);
            Assert.AreEqual(rover.Position.Y, 3);
            Assert.AreEqual(rover.Position.Direction, DirectionEnum.North);
        }
Пример #9
0
        public void MarsRoverTest_InitialPosition22W_MoveBackward_FinalPosition32W()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

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

            rover.MoveBackward();

            Assert.AreEqual(rover.Position.X, 3);
            Assert.AreEqual(rover.Position.Y, 2);
            Assert.AreEqual(rover.Position.Direction, DirectionEnum.West);
        }
Пример #10
0
        public void MarsRoverTest_InitialPosition11DirE_SendCommands_LRFFFFFLRLF_FinalPosition_20N()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

            Rover rover = new RoverBuilder()
                          .WithWorld(world)
                          .WithInitialDirectionEast()
                          .WithInitialPosition(1, 1)
                          .Build();

            string[] movements = { "L", "R", "F", "F", "F", "F", "L", "R", "L", "F" };


            rover.Move(movements);

            Assert.AreEqual(2, rover.Position.X);
            Assert.AreEqual(0, rover.Position.Y);
            Assert.AreEqual(DirectionEnum.North, rover.Position.Direction);
        }