Пример #1
0
        public void ObstacleHandlerWithoutCellRevisit()
        {
            //Move 3 cells forward to reach the corner
            RobotUtility.MoveForward(_algorithmEssentials);
            RobotUtility.MoveForward(_algorithmEssentials);
            RobotUtility.MoveForward(_algorithmEssentials);

            // now ask the obstacle handler to handle it
            Assert.True(_firstObstacleHandler.HandleMovement());

            //Move 2 cells forward to reach the corner
            RobotUtility.MoveForward(_algorithmEssentials);
            RobotUtility.MoveForward(_algorithmEssentials);

            // now ask the obstacle handler to handle it
            Assert.True(_firstObstacleHandler.HandleMovement());

            //Move 2 cells forward to reach the corner
            RobotUtility.MoveForward(_algorithmEssentials);
            RobotUtility.MoveForward(_algorithmEssentials);

            // now ask the obstacle handler to handle it
            Assert.True(_firstObstacleHandler.HandleMovement());

            //Move 1 cell forward to reach the visited cell
            RobotUtility.MoveForward(_algorithmEssentials);

            // now ask the obstacle handler to handle it
            Assert.True(_firstObstacleHandler.HandleMovement());

            //Move 1 cell forward to reach the center cell
            RobotUtility.MoveForward(_algorithmEssentials);

            _secondObstacleHandler = new ObstacleHandler(_algorithmEssentials);
            _thirdObstacleHandler  = new ObstacleHandler(_algorithmEssentials);
            _firstObstacleHandler.SetNextMovementHandler(_secondObstacleHandler);
            _secondObstacleHandler.SetNextMovementHandler(_thirdObstacleHandler);

            //all the three obstacle handlers will fail to handle the case
            Assert.False(_firstObstacleHandler.HandleMovement());
        }
Пример #2
0
        public void ForwardMovementHandlerWithCellRevisit()
        {
            //Move 3 cells forward to reach the corner
            RobotUtility.MoveForward(_algorithmEssentials);
            RobotUtility.MoveForward(_algorithmEssentials);
            RobotUtility.MoveForward(_algorithmEssentials);

            // now ask the obstacle handler to handle it
            Assert.True(_firstObstacleHandler.HandleMovement());

            //Move 2 cells forward to reach the corner
            RobotUtility.MoveForward(_algorithmEssentials);
            RobotUtility.MoveForward(_algorithmEssentials);

            // now ask the obstacle handler to handle it
            Assert.True(_firstObstacleHandler.HandleMovement());

            //Move 2 cells forward to reach the corner
            RobotUtility.MoveForward(_algorithmEssentials);
            RobotUtility.MoveForward(_algorithmEssentials);

            // now ask the obstacle handler to handle it
            Assert.True(_firstObstacleHandler.HandleMovement());

            //Move 1 cell forward to reach the visited cell
            RobotUtility.MoveForward(_algorithmEssentials);

            // now ask the obstacle handler to handle it
            Assert.True(_firstObstacleHandler.HandleMovement());

            //Move 1 cell forward to reach the center cell
            RobotUtility.MoveForward(_algorithmEssentials);

            //when cell revisit is enabled the obstacle handler can handle
            Assert.True(_obstacleHandlerWithCellRevisit.HandleMovement());
        }