Esempio n. 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);
        }
Esempio n. 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);
        }