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)); }
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); }
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); }
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)); }