Esempio n. 1
0
        public void Move_Forward_ReturnsRightPosition(DirectionType currentDirection, int currentPositionX, int currentPositionY, int expectedPositionX, int expectedPositionY)
        {
            Rover rover = new Rover(currentDirection);

            rover.Position = new Position(currentPositionX, currentPositionY);
            rover.Move();
            Assert.Equal(expectedPositionX, rover.Position.X);
            Assert.Equal(expectedPositionY, rover.Position.Y);
        }
Esempio n. 2
0
        public void TestIfRoverThrowsErrorIfMadeToFall()
        {
            var rover = new Rover();

            rover.Stand(new Point(4, 4), Direction.NORTH);

            Assert.Throws <ApplicationException>(() =>
            {
                rover.Move();
            });
        }
        public void When_The_Rover_Is_Created_Turn_Right_And_Move_Rover_Will_Be_At_Coordinates_1_0()
        {
            int  xCoordinate = 0;
            int  yCoordinate = 0;
            char oriantation = 'N';
            var  rover       = new Rover(xCoordinate, yCoordinate, oriantation, _plateaue);

            rover.TurnRight();
            rover.Move();
            Assert.Equal(1, rover.XCoordinate);
            Assert.Equal(0, rover.YCoordinate);
        }
        public void When_Rover_IsCreated_At_North_And_Move_TheRover_WillBe_0_1_Coordinate()
        {
            int  xCoordinate = 0;
            int  yCoordinate = 0;
            char oriantation = 'N';

            var rover = new Rover(xCoordinate, yCoordinate, oriantation, _plateaue);

            rover.Move();
            Assert.Equal(0, rover.XCoordinate);
            Assert.Equal(1, rover.YCoordinate);
        }
Esempio n. 5
0
        public void TestIfRoverMovesBackwardsOnXAxis()
        {
            var rover = new Rover();

            rover.Stand(new Point(1, 1), Direction.WEST);

            rover.Move();

            Assert.AreEqual(rover.Position.X, 0);
            Assert.AreEqual(rover.Position.Y, 1);
            Assert.AreEqual(rover.Direction, Direction.WEST);
        }
Esempio n. 6
0
        public void Test4()
        {
            var position = new Position(0, 1, 'S');

            _rover = new Rover(position);
            _rover.Move("MMLMT");
            var result = _rover.GetCurrentPosition();

            Assert.Equal(2, result.X);
            Assert.Equal(1, result.Y);
            Assert.Equal(Application.Constants.DirectionType.N, result.FaceDirectionType);
        }
Esempio n. 7
0
        public void TestIfRoverMovesForwardOnYAxis()
        {
            var rover = new Rover();

            rover.Stand(new Point(1, 1), Direction.NORTH);

            rover.Move();

            Assert.AreEqual(rover.Position.X, 1);
            Assert.AreEqual(rover.Position.Y, 2);
            Assert.AreEqual(rover.Direction, Direction.NORTH);
        }
Esempio n. 8
0
        public void RoverPerformans()
        {
            Rover rover  = new Rover(100000, 1000000);
            var   result = rover.Move(2434, 32233, "N", "LLMLRMMMRRRLRMMMMMRRRRMMRRMMMMMRRLMMMMRRMMMMMRRLMMMLLMLRMMMRRRLRMMMMMRRRRMMRRLLMLRMMMRRRLRMMMMMRRRLRMMRRLLMLRMMMRRRLRMMMMMLRRRRMMRRLLMLRMMLMRRRLRMMMMMRRRRMMRRMM");

            if (!result.IsError)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail(result.Message);
            }
        }
Esempio n. 9
0
        public void CanMoveDown()
        {
            //  arrange
            const int x = 1;
            const int y = 2;
            const CardinalDirection cardinalDirection = CardinalDirection.South;
            var rover = new Rover(x, y, cardinalDirection);

            //  act
            rover.Move();

            //  assert
            Assert.AreEqual(1, rover.Position.Coordinate.Y);
        }
Esempio n. 10
0
        public void CanMoveRight()
        {
            //  arrange
            const int x = 3;
            const int y = 2;
            const CardinalDirection cardinalDirection = CardinalDirection.East;
            var rover = new Rover(x, y, cardinalDirection);

            //  act
            rover.Move();

            //  assert
            Assert.AreEqual(4, rover.Position.Coordinate.X);
        }
Esempio n. 11
0
        public void Test1()
        {
            Rover rover  = new Rover(10, 10);
            var   result = rover.Move(2, 3, "N", "LLMLRMMM");

            if (!result.IsError)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail(result.Message);
            }
        }
Esempio n. 12
0
        public void TestScanrio_23S_MMMRRLLLRMRMLLMR()
        {
            Coords maxPoints = new Coords(10, 10);
            Rover  rover     = new Rover(maxPoints);

            var    moves           = "MMRRLLLRMRLLMR";
            Coords currentPosition = new Coords(2, 3);

            rover.Move(currentPosition, Directions.S, moves);

            var actualOutput   = $"{rover.CurrentPosition.X} {rover.CurrentPosition.Y} {rover.Direction}";
            var expectedOutput = "3 0 S";

            Assert.Equal(expectedOutput, actualOutput);
        }
Esempio n. 13
0
        public void initialposition_12N_message_LMLMLMLMM_finalposition_13N()
        {
            Plateau.SetUpperCoordinate(5, 5);
            ISpaceCompany company = new Nasa();
            var           rover   = new Rover(new Position(1, 2, Direction.N));

            company.Subscribe(rover);
            var message = new Message("LMLMLMLMM");

            rover.Move(message);
            var finalPositionOfRover = rover.GetFinalPosition();
            var expectedResult       = "1 3 N";

            Assert.AreEqual(expectedResult, finalPositionOfRover);
        }
Esempio n. 14
0
        public void TestScanrio_21W_RRMMMLRLLMR()
        {
            Coords maxPoints = new Coords(5, 5);
            Rover  rover     = new Rover(maxPoints);

            var    moves           = "RRMMMLRLLMR";
            Coords currentPosition = new Coords(2, 1);

            rover.Move(currentPosition, Directions.W, moves);

            var actualOutput   = $"{rover.CurrentPosition.X} {rover.CurrentPosition.Y} {rover.Direction}";
            var expectedOutput = "4 1 N";

            Assert.Equal(expectedOutput, actualOutput);
        }
Esempio n. 15
0
        public void initialposition_33E_message_MMRMMRMRRM_finalposition_51E()
        {
            Plateau.SetUpperCoordinate(5, 5);
            ISpaceCompany company = new Nasa();
            var           rover   = new Rover(new Position(3, 3, Direction.E));

            company.Subscribe(rover);
            var message = new Message("MMRMMRMRRM");

            rover.Move(message);
            var finalPositionOfRover = rover.GetFinalPosition();
            var expectedResult       = "5 1 E";

            Assert.AreEqual(expectedResult, finalPositionOfRover);
        }
Esempio n. 16
0
        public void RoverMoveShould()
        {
            var expectedResult = new Position {
                X = 0, Y = 1
            };
            var rover = new Rover {
                Direction = Direction.North, Position = new Position {
                    X = 0, Y = 0
                }
            };

            rover.Move();

            Assert.Equal(expectedResult.X, rover.Position.X);
            Assert.Equal(expectedResult.Y, rover.Position.Y);
        }
Esempio n. 17
0
        public void TestScenario_ThrowException()
        {
            Coords maxPoints = new Coords(1, 1);
            Rover  rover     = new Rover(maxPoints);

            var    moves           = "LMLMLMLMM";
            Coords currentPosition = new Coords(1, 2);

            var exception = Assert.Throws <Exception>(() =>
            {
                rover.Move(currentPosition, Directions.N, moves);
            });

            var expectedExceptionMsg = $"Oops! Position can not be beyond bounderies (0 , 0) and ({maxPoints.X} , {maxPoints.Y})";

            Assert.Equal(expectedExceptionMsg, exception.Message);
        }