Example #1
0
        public void MoveFromNordDirection_ObstaclePoint_ThrowException()
        {
            var       B = new Backward();
            RoverMars R = new RoverMars('N');

            // this case should never happen but this class does not know
            // i give to the rover an impossible point
            R.Position.X = 2;
            R.Position.Y = 3;
            Grid G = new Grid(5, 5, new FakeObstacleGenerator());

            B.MoveFromNordDirection(R, G);
        }
Example #2
0
        public void MoveFromNordDirection_NewRoverPoint_OutOfGrid_Expected_NewYEqualsZero()
        {
            var       B = new Backward();
            RoverMars R = new RoverMars('N');

            R.Position.X = 1;
            R.Position.Y = 7;
            Grid G = new Grid(5, 5, new FakeObstacleGenerator());

            B.MoveFromNordDirection(R, G);
            Point expectedNewRoverPosition = new Point(1, 0);

            Assert.AreEqual(expectedNewRoverPosition, R.Position);
        }
Example #3
0
        public void MoveFromNordDirection_MoveRoverInYMinusOne()
        {
            var       B = new Backward();
            RoverMars R = new RoverMars('N');

            R.Position.X = 1;
            R.Position.Y = 1;
            Grid G = new Grid(5, 5, new FakeObstacleGenerator());

            B.MoveFromNordDirection(R, G);
            Point expectedNewRoverPosition = new Point(1, 0);

            Assert.AreEqual(expectedNewRoverPosition, R.Position);
        }
Example #4
0
        public void MoveFromNordDirection_NewRoverPoint_OutOfGridValueLessThenZero_Expected_NewYEqualsMaxYOfGrid()
        {
            var       B = new Backward();
            RoverMars R = new RoverMars('N');

            // this case should never happen but this class does not know
            // i give to the rover an impossible point
            R.Position.X = 1;
            R.Position.Y = 0;
            Grid G = new Grid(5, 5, new FakeObstacleGenerator());

            B.MoveFromNordDirection(R, G);
            Point expectedNewRoverPosition = new Point(1, 5);

            Assert.AreEqual(expectedNewRoverPosition, R.Position);
        }