Пример #1
0
        public void ShouldThrowInvalidMoveExceptionIfCellIsAlreadyRevealed()
        {
            var revealedCoordinate = new Coordinate(1, 1);

            _gameBoard.GetCell(revealedCoordinate).CellState = CellState.Revealed;

            var flagCommand = new FlagCommand(revealedCoordinate);

            Assert.Throws <InvalidMoveException>(() => flagCommand.Execute(_gameBoard));
        }
Пример #2
0
        public void ShouldSetSelectedCellStateToFlagged()
        {
            var flagCoordinate = new Coordinate(1, 1);
            var flagCommand    = new FlagCommand(flagCoordinate);

            flagCommand.Execute(_gameBoard);

            var result = _gameBoard.GetCell(flagCoordinate).CellState;

            Assert.Equal(CellState.Flagged, result);
        }
Пример #3
0
        public void ShouldSetCellStateToUnrevealedIfAlreadyFlagged()
        {
            var flagCoordinate = new Coordinate(1, 1);

            _gameBoard.GetCell(flagCoordinate).CellState = CellState.Flagged;
            var flagCommand = new FlagCommand(flagCoordinate);

            flagCommand.Execute(_gameBoard);

            var result = _gameBoard.GetCell(flagCoordinate).CellState;

            Assert.Equal(CellState.Unrevealed, result);
        }
Пример #4
0
        public void ShouldThrowInvalidMoveException_IfTyringToFlagMoreFlagsThanMines()
        {
            // Plant 2 mines
            _gameBoard.GetCell(new Coordinate(4, 4)).PlantMine();
            _gameBoard.GetCell(new Coordinate(5, 5)).PlantMine();
            // Flag 2 cells that aren't mines
            _gameBoard.GetCell(new Coordinate(2, 2)).CellState = CellState.Flagged;
            _gameBoard.GetCell(new Coordinate(1, 1)).CellState = CellState.Flagged;

            // Flagging the third cell
            var flagCommand = new FlagCommand(new Coordinate(4, 4));

            Assert.Throws <InvalidMoveException>(() => flagCommand.Execute(_gameBoard));
        }