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);
        }
Esempio n. 3
0
        public void Should_ThrowPointValidationException_When_TurtlePointsAreInvalid(int locationX, int locationY)
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 5));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _turtleSetCommand = new TurtleSetCommand(new TurtlePoint(locationX, locationY, Direction.North));
            _turtleSetCommand.Set(_board, _turtle);

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

            Assert.Equal("Turtle point is not valid!", exception.Message);
        }
Esempio n. 4
0
        public void Should_ReturnSpecifiedTurtlePointAndDirection_When_GivenParamtersAreValid()
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

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

            Assert.Equal(1, _turtle.Point.X);
            Assert.Equal(3, _turtle.Point.Y);
            Assert.Equal(Direction.North, _turtle.Point.Direction);
        }