Esempio n. 1
0
        public void MoveFromEstDirection_ObstaclePoint_ThrowException()
        {
            var       B = new Backward();
            RoverMars R = new RoverMars('E');

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

            B.MoveFromEstDirection(R, G);
        }
Esempio n. 2
0
        public void MoveFromEstDirection_NewRoverPoint_OutOfGrid_Expected_NewXEqualsZero()
        {
            Backward  B = new Backward();
            RoverMars R = new RoverMars('E');

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

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

            Assert.AreEqual(expectedNewRoverPosition, R.Position);
        }
Esempio n. 3
0
        public void MoveFromEstDirection_MoveRoverInXMinusOne()
        {
            var       B = new Backward();
            RoverMars R = new RoverMars('E');

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

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

            Assert.AreEqual(expectedNewRoverPosition, R.Position);
        }
Esempio n. 4
0
        public void MoveFromEstDirection_NewRoverPoint_OutOfGridValueLessThenZero_Expected_NewXEqualsMaxXOfGrid()
        {
            var       B = new Backward();
            RoverMars R = new RoverMars('E');

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

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

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