Exemple #1
0
        public void MoveForward(double currentXCoordinate, double currentYCoordinate, Orientation currentOrientation, double newXCoordinate, double newYCoordinate)
        {
            _sut.CurrentPosition    = new Position(currentXCoordinate, currentYCoordinate);
            _sut.CurrentOrientation = currentOrientation;

            var newPosition = new Position(newXCoordinate, newYCoordinate);

            _mockNavigationAdvisor.Setup(x => x.CalculateDestinationPosition(It.IsAny <Position>(), It.IsAny <Orientation>(), 1)).Returns(newPosition);

            _mockValidator.Setup(x => x.PositionInRange(It.IsAny <Position>(), It.IsAny <Position>(), It.IsAny <Position>(), It.IsAny <string>()));

            _sut.MoveForward();
            Assert.Equal(newPosition, _sut.CurrentPosition);
        }
        public void ShouldMoveForward()
        {
            var rover = new Rover(1, 2, Direction.North);

            rover = rover.MoveForward();

            rover.Position.Y.Should().Be(3);
        }
Exemple #3
0
        public void WrapAtEdgeWhenMoveForward(Coordinate coordinate, char direction, World world, int expectedXCoord, int expectedYCoord)
        {
            var rover = new Rover(coordinate, direction, world);

            rover.MoveForward();

            Assert.Equal(expectedXCoord, rover.GetCoordinate().GetXCoordinate());
            Assert.Equal(expectedYCoord, rover.GetCoordinate().GetYCoordinate());
        }
Exemple #4
0
        public void MoveForward(int initialX, int initialY, char initialDirection, int expectedX, int expectedY, char expectedDirection)
        {
            var coordinate = new Coordinate(initialX, initialY);
            var world      = new World(5, 5);
            var rover      = new Rover(coordinate, initialDirection, world);

            rover.MoveForward();

            Assert.Equal(expectedX, rover.GetCoordinate().GetXCoordinate());
            Assert.Equal(expectedY, rover.GetCoordinate().GetYCoordinate());
            Assert.Equal(expectedDirection, rover.GetDirection());
        }
Exemple #5
0
        public void NotMoveForwardIfThereIsObstacle(int xCoord, int yCoord, char direction, World world, Coordinate obstacle)
        {
            var coordinate = new Coordinate(xCoord, yCoord);

            world.SetObstacle(obstacle);
            var rover = new Rover(coordinate, direction, world);

            var exception = Assert.Throws <Exception>(() => rover.MoveForward());

            Assert.Equal($"Bump into obstacle at {obstacle.GetXCoordinate()},{obstacle.GetYCoordinate()}", exception.Message);
            Assert.Equal(xCoord, rover.GetCoordinate().GetXCoordinate());
            Assert.Equal(yCoord, rover.GetCoordinate().GetYCoordinate());
        }
Exemple #6
0
        public void MoveForward_RoverOrientationWest_DecreaseX()
        {
            var plateau            = new Plateau("5 5");
            var mockCommandFactory = new Mock <ICommandFactory>();

            mockCommandFactory.Setup(a => a.GetCommand(It.IsAny <char>())).Returns(new MoveCommand());

            var rover = new Rover(plateau, mockCommandFactory.Object);

            rover.SetPosition(new SetPositionDTO {
                PositionLetter = "1 1 W"
            });
            rover.MoveForward();

            Assert.Equal("0 1 W", rover.GetPosition());
        }
Exemple #7
0
        public void Rover_WhenMoveForward_ThenMovedForward()
        {
            //Given
            ILocation location = new Location(_defaultMarsArea, _defaultRoverLocation);
            IRover    rover    = new Rover(new NorthState(), location);

            //When
            rover.MoveForward();

            //Then
            RoverLocation expectedRoverLocation = new RoverLocation()
            {
                CurrentXaxis = 2, CurrentYaxis = 3
            };

            rover.GetLocation().GetRoverLocation().Should().BeEquivalentTo(expectedRoverLocation);
        }