public void Should_ThrowPointValidationException_When_TheInvalidMinePointsAreGiven(int locationX, int locationY)
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 5));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _mineSetCommand = new MineSetCommand(new Point(locationX, locationY));
            _mineSetCommand.Set(_board, _mine);

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

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

            _mineSetCommand = new MineSetCommand(new Point(1, 2));
            _mineSetCommand.Set(_board, _mine);
            _mineSetCommand.Execute();

            Assert.Equal(1, _mine.Point.X);
            Assert.Equal(2, _mine.Point.Y);
        }
Beispiel #3
0
        public void Should_ReturnMineHit_When_GivenTheSpecifiedInputs()
        {
            var movements = new List <Movement>
            {
                Movement.Right,
                Movement.Move,
                Movement.Left,
                Movement.Move
            };

            var mines = new List <IMine> {
                _mine
            };

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

            _mineSetCommand = new MineSetCommand(new Point(1, 2));
            _mineSetCommand.Set(_board, _mine);
            _mineSetCommand.Execute();

            _exitSetCommand = new ExitSetCommand(new Point(3, 3));
            _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("Mine Hit", _turtle.Result);
        }