Exemple #1
0
        public void MoveFromSudDirection_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 = 1;
            Grid G = new Grid(5, 5, new FakeObstacleGenerator());

            B.MoveFromSudDirection(R, G);
        }
Exemple #2
0
        public void MoveFromSudDirection_MoveRoverInYPlusOne()
        {
            var       B = new Backward();
            RoverMars R = new RoverMars('S');

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

            B.MoveFromSudDirection(R, G);
            Point expectedNewRoverPosition = new Point(1, 2);

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

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

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

            Assert.AreEqual(expectedNewRoverPosition, R.Position);
        }
Exemple #4
0
        public void MoveFromSudDirection_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 = -2;
            Grid G = new Grid(5, 5, new FakeObstacleGenerator());

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

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