Exemple #1
0
        public void MarsRoverTest_InitialPositionNotValidY_ExpectedArgumentException()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

            Rover rover = new Rover();

            rover.Initialize(1, -1, DirectionEnum.North, world);
        }
        public void MarsServiceTest_LandRover_Position23DirE()
        {
            IWorld world       = WorldBuilder.GetDefault5x5World();
            var    marsService = Substitute.For <MarsService>(world);

            Position position = marsService.LandRover(2, 3, DirectionEnum.East);

            Assert.AreEqual(2, position.X);
            Assert.AreEqual(3, position.Y);
            Assert.AreEqual(DirectionEnum.East, position.Direction);
        }
Exemple #3
0
        public void MarsRoverTest_InitializPosition0_0_E_InitialiPositionPoint0_0_Direction_E()
        {
            Rover rover = new Rover();

            IWorld world = WorldBuilder.GetDefault5x5World();

            rover.Initialize(0, 0, DirectionEnum.East, world);

            Assert.AreEqual(0, rover.Position.X);
            Assert.AreEqual(0, rover.Position.Y);
            Assert.AreEqual(DirectionEnum.East, rover.Position.Direction);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
        public void MarsServiceTest_MoveRoverFFRRLLBB_Start23E_End21E()
        {
            IWorld world       = WorldBuilder.GetDefault5x5World();
            var    marsService = Substitute.For <MarsService>(world);

            marsService.LandRover(2, 3, DirectionEnum.East);

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

            Position position = marsService.MoveRover(commands);

            Assert.AreEqual(2, position.X);
            Assert.AreEqual(1, position.Y);
            Assert.AreEqual(DirectionEnum.East, position.Direction);
        }
Exemple #7
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);
        }
Exemple #8
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);
        }
Exemple #9
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);
        }
Exemple #10
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);
        }
Exemple #11
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);
        }
Exemple #12
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);
        }
Exemple #13
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);
        }
        public void MarsServiceTest_CanInstantiate()
        {
            IWorld world = WorldBuilder.GetDefault5x5World();

            Assert.IsNotNull(new MarsService(world));
        }