Example #1
0
        public void IsLosingConditionShould_ReturnFalse_WhenNoMineOnBoardIsRevealed()
        {
            var board         = Board.CreateEmptyBoard(2);
            var mineGenerator = new MockMinesGenerator();

            mineGenerator.PlaceMines(2, board);
            var result = WinLoseChecker.IsLosingConditionWhenOneMineIsRevealed(board);

            Assert.False(result);
        }
Example #2
0
        public void ToStringShould_ReturnExpectedString_WhenThereIs1RevealedTopLeftMineInASize2Board()
        {
            var          mineGenerator  = new MockMinesGenerator();
            const string expectedString = "* 1 \n" + "1 1 \n";
            var          board          = Board.CreateEmptyBoard(2);

            mineGenerator.PlaceMines(1, board);
            HintGenerator.SetHints(board);
            board.RevealAllSquares();
            Assert.Equal(expectedString, board.ToString());
        }
Example #3
0
        public void PlaceMinesShould_SetSquaresOnTheTopRowToMines_WhenThereAre2MinesOnASize2Board()
        {
            var board          = Board.CreateEmptyBoard(2);
            var minesGenerator = new MockMinesGenerator();

            minesGenerator.PlaceMines(2, board);
            board.RevealAllSquares();

            const string expectedResult = "* * \n" +
                                          "0 0 \n";

            Assert.Equal(expectedResult, board.ToString());
        }
Example #4
0
        public void IsLosingConditionShould_ReturnTrue_WhenOneMineOnBoardAreRevealed()
        {
            var board         = Board.CreateEmptyBoard(2);
            var mineGenerator = new MockMinesGenerator();

            mineGenerator.PlaceMines(2, board);
            var topLeft = new Location(0, 0);
            var mineOne = board.GetSquare(topLeft);

            mineOne.Reveal();
            var result = WinLoseChecker.IsLosingConditionWhenOneMineIsRevealed(board);

            Assert.True(result);
        }
Example #5
0
        public void IsWinningConditionShould_ReturnFalse_WhenOneHintsOnBoardIsRevealed()
        {
            var board         = Board.CreateEmptyBoard(2);
            var mineGenerator = new MockMinesGenerator();

            mineGenerator.PlaceMines(2, board);
            var bottomLeft = new Location(1, 0);
            var hintOne    = board.GetSquare(bottomLeft);

            hintOne.Reveal();
            var result = WinLoseChecker.IsWinningConditionWhenAllHintsAreRevealed(board);

            Assert.False(result);
        }