예제 #1
0
        public void MarsRoverTest_ButtomEdgeDirSouth_MoveForward_RoverStepInTopEdge()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

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

            rover.MoveForward();
            Assert.AreEqual(world.GetTopEdgeYCoordinates(), rover.Position.Y);
        }
예제 #2
0
        public void MarsRoverTest_RightEdgeDirEast_MoveForward_RoverStepInLeftEdge()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

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

            rover.MoveForward();
            Assert.AreEqual(world.GetLeftEdgeXCoordinates(), rover.Position.X);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
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);
        }