Пример #1
0
        public void Should_ReturnSuccess_When_GivenTheSpecifiedInputs()
        {
            var movements = new List <Movement>
            {
                Movement.Right,
                Movement.Move,
                Movement.Move,
                Movement.Move
            };

            var mines = new List <IMine>();

            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _exitSetCommand = new ExitSetCommand(new Point(3, 1));
            _exitSetCommand.Set(_board, _exit);
            _exitSetCommand.Execute();

            _turtleSetCommand = new TurtleSetCommand(new TurtlePoint(0, 1, Direction.North));
            _turtleSetCommand.Set(_board, _turtle);
            _turtleSetCommand.Execute();

            _turtleMoveCommand = new TurtleMoveCommand(movements);
            _turtleMoveCommand.Set(_turtle, mines, _exit);
            _turtleMoveCommand.Execute();

            Assert.Equal("Success", _turtle.Result);
        }
Пример #2
0
        public void Should_ThrowPointValidationException_When_TheAppHasInvalidPoints()
        {
            var movements = new List <Movement>
            {
                Movement.Right,
                Movement.Move,
                Movement.Move,
                Movement.Move,
                Movement.Move,
                Movement.Move,
                Movement.Move
            };

            var mines = new List <IMine>();

            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _exitSetCommand = new ExitSetCommand(new Point(3, 1));
            _exitSetCommand.Set(_board, _exit);
            _exitSetCommand.Execute();

            _turtleSetCommand = new TurtleSetCommand(new TurtlePoint(0, 1, Direction.North));
            _turtleSetCommand.Set(_board, _turtle);
            _turtleSetCommand.Execute();

            _turtleMoveCommand = new TurtleMoveCommand(movements);
            _turtleMoveCommand.Set(_turtle, mines, _exit);
            _turtleMoveCommand.Execute();

            var exception = Assert.Throws <PointValidationException>(() => _turtleMoveCommand.Execute());

            Assert.Equal("Turtle cannot go out of board!", exception.Message);
        }
Пример #3
0
        public void Should_ThrowPointValidationException_When_TheExistPointParametersAreInvalid(int locationX, int locationY)
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 5));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _exitSetCommand = new ExitSetCommand(new Point(locationX, locationY));
            _exitSetCommand.Set(_board, _exit);

            var exception = Assert.Throws <PointValidationException>(() => _exitSetCommand.Execute());

            Assert.Equal("Exit point is not valid!", exception.Message);
        }
Пример #4
0
        public void Should_ReturnTheGivenExitPoint_When_TheExistPointParametersAreValid()
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _exitSetCommand = new ExitSetCommand(new Point(3, 3));
            _exitSetCommand.Set(_board, _exit);
            _exitSetCommand.Execute();

            Assert.Equal(3, _exit.Point.X);
            Assert.Equal(3, _exit.Point.Y);
        }