public void TestGetAdjacentSquaresInCorner()
        {
            Board board = new Board(9, 9, 0);

            board.FillBoardSquares();
            BoardSquare[]      testAdjacentSquares = { board.GetSquare(0, 7), board.GetSquare(1, 7), board.GetSquare(1, 8) };
            List <BoardSquare> adjacentSquares     = board.GetAdjacentSquares(board.GetSquare(0, 8));

            adjacentSquares.Should().BeSubsetOf(testAdjacentSquares);
        }
        public void TestThatBombsSeededInRightPlace()
        {
            Board board = new Board(9, 9, 3);

            board.FillBoardSquares();
            var randomSquares = board.GetRandomSquares();

            board.PlaceBombs(randomSquares);
            randomSquares.Should().OnlyContain(s => s.value == BoardSquare.BOMB);
        }
        public void TestGetAdjacentSquares()
        {
            Board board = new Board(9, 9, 0);

            board.FillBoardSquares();
            BoardSquare[]      testAdjacentSquares = { board.GetSquare(2, 2), board.GetSquare(2, 3), board.GetSquare(2, 4), board.GetSquare(3, 2), board.GetSquare(3, 4), board.GetSquare(4, 2), board.GetSquare(4, 3), board.GetSquare(4, 4) };
            List <BoardSquare> adjacentSquares     = board.GetAdjacentSquares(board.GetSquare(3, 3));

            adjacentSquares.Should().BeSubsetOf(testAdjacentSquares);
        }
        public void TestGetSquaresList()
        {
            Board board = new Board(9, 9, 0);

            board.FillBoardSquares();
            List <BoardSquare> squares = board.GetSquaresList();

            squares.Should().OnlyHaveUniqueItems();
            squares.Should().HaveCount(9 * 9);
        }
        public void TestFillBoardValues()
        {
            Board       board = new Board(9, 9, 9);
            BoardSquare square;

            board.FillBoardSquares();
            board.PlaceBombs(board.GetRandomSquares(2));
            board.FillBoardValues();
            square = board.GetSquare(1, 6);
            square.value.Should().Be(2);
        }
        public void TestGetRandomSquaresIsDifferentEveryTime()
        {
            Board board = new Board(9, 9, 4);

            board.FillBoardSquares();
            var randomSquares1 = board.GetRandomSquares();

            //delay to give time for random to make new seed
            Thread.Sleep(100);
            var randomSquares2 = board.GetRandomSquares();

            randomSquares1.Union(randomSquares2).Count().Should().NotBe(randomSquares1.Count());
        }
        public void TestOpenZeroesWhenAllZeros()
        {
            Board board = new Board(9, 9, 0);

            board.FillBoardSquares();
            board.FillBoardValues();
            board.OpenZeros(board.GetSquare(2, 2));
            var squareOpens =
                from square in board.GetSquaresList()
                select square.isOpen;

            squareOpens.Should().OnlyContain(s => s == true);
        }
        public void TestOpenZerosWithOneBomb()
        {
            Board board = new Board(4, 4, 0);

            board.FillBoardSquares();
            board.GetSquare(0, 0).value = BoardSquare.BOMB;
            board.FillBoardValues();
            board.OpenZeros(board.GetSquare(2, 2));
            var openCount =
                (from square in board.GetSquaresList()
                 where square.isOpen == true
                 select square.isOpen).Count();

            openCount.Should().Be(15);
        }