public void AreaPopShouldPopCorrectlyOnCorner()
        {
            var effect = new AreaPopEffect();
             var board = new Board(8, 8, new RandomGenerator());
             effect.Pop(0, 0, board);

             for (int row = 0; row < 8; row++)
             {
                 for (int col = 0; col < 8; col++)
                 {
                     if (row < 2 && col < 2)
                     {
                         if (board[row, col] != Balloon.Default)
                         {
                             Assert.Fail("Balloons didn't pop.");
                         }
                     }
                     else
                     {
                         if (board[row, col] == Balloon.Default)
                         {
                             Assert.Fail("Too many balloons popped.");
                         }
                     }
                 }
             }
        }
        public void BoardContainsDifferentValuesAfterResetIsExecuted()
        {
            var size = 5;
            var board = new Board(size, size, this.randomGenerator);

            var oldBoard = new int[size, size];

            for (int i = 0; i < board.Rows; i++)
            {
                for (int j = 0; j < board.Cols; j++)
                {
                    oldBoard[i, j] = board[i, j].Value;
                }
            }

            board.Reset();

            var matricesAreDifferent = false;

            for (int i = 0; i < board.Rows; i++)
            {
                for (int j = 0; j < board.Cols; j++)
                {
                    if (oldBoard[i, j] != board[i, j].Value)
                    {
                        matricesAreDifferent = true;
                    }
                }
            }

            Assert.IsTrue(matricesAreDifferent);
        }
        public void BoardIsValidPopShouldReturnFalseWhenNullBalloonPositionsArePassed()
        {
            var board = new Board(5, 5, this.randomGenerator);

            board[1, 1] = null;

            Assert.IsFalse(board.IsValidPop(1, 1));
        }
        public void BfsEffectShouldPopAtLeastOneBalloon()
        {
            var effect = new BfsEffect();
            var board = new Board(8, 8, new RandomGenerator());
            effect.Pop(4, 4, board);

            var hasPoppedBalloon = false;

            for (int col = 0; col < 8; col++)
            {
                if (board[0, col] == Balloon.Default)
                {
                    hasPoppedBalloon = true;
                    break;
                }
            }

            Assert.IsTrue(hasPoppedBalloon);
        }
        public void BoardRestoreMementoShouldRestoreBoardToPreviousState()
        {
            var board = new Board(5, 5, this.randomGenerator);
            var memento = board.SaveMemento();

            board[0, 0] = null;
            board[1, 1] = null;
            board[1, 0] = null;

            board.RestoreMemento(memento);

            if (board[0, 0] != null && board[1, 1] != null && board[1, 0] != null)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
        public void BoardIsValidPopShouldReturnTrueWhenExistingValuesAreProvided()
        {
            var board = new Board(5, 5, this.randomGenerator);

            Assert.IsTrue(board.IsValidPop(3, 3));
        }
        public void BoardIsValidPopShouldReturnFalseWhenInvalidArgumentsAreProvided()
        {
            var board = new Board(5, 5, this.randomGenerator);

            Assert.IsFalse(board.IsValidPop(6, 6));
        }
 public void BoardWithValidRowsAndColumnsParametersShouldBeCreated(
     [Values(5, 7, 10, 13, 15)] int validSize)
 {
     var board = new Board(validSize, validSize,this.randomGenerator);
 }
 public void BoardWithValidRowsAndInvalidColumnsParametersShouldThrow()
 {
     var board = new Board(5, 4, this.randomGenerator);
 }
 public void BoardWithInvalidRowsAndColumnsParametersShouldThrow(
     [Values(1, 3, 16, 17)] int invalidSize)
 {
     var board = new Board(invalidSize, invalidSize, this.randomGenerator);
 }
        public void BoardUnpoppedBalloonsCountShouldReturnValidAmountWhenThereArePoppedBalloons()
        {
            var size = 5;
            var board = new Board(size, size, this.randomGenerator);

            board[3, 3] = null;
            board[2, 2] = null;

            var balloonsCount = board.UnpoppedBalloonsCount;
            var expected = (size * size) - 2;

            Assert.AreEqual(expected, balloonsCount);
        }
        public void BoardUnpoppedBalloonsCountShouldReturnInitialAmountOfBalloons()
        {
            var size = 5;
            var board = new Board(size, size, this.randomGenerator);

            var initialBalloonsCount = board.UnpoppedBalloonsCount;
            var expected = size * size;

            Assert.AreEqual(expected, initialBalloonsCount);
        }
        public void BoardToStringShouldReturnValidStringRepresentation()
        {
            var board = new Board(5, 5, this.randomGenerator);
            var expectedString =
                "    0 1 2 3 4 \r\n    ----------\r\n0 | . 1 1 1 1 | \r\n1 | 1 1 1 1 1 | \r\n2 | 1 1 1 1 1 | \r\n3 | 1 1 1 1 1 | \r\n4 | 1 1 1 1 1 | \r\n    ----------\r\n";

            SetBoardMatrix(board);

            var resultingString = board.ToString();

            Assert.AreEqual(expectedString, resultingString);
        }
        public void BoardSaveMementoShouldReturnAMemento()
        {
            var board = new Board(5, 5, this.randomGenerator);
            var memento = board.SaveMemento().Board;

            var boardAsMatrix = new IBalloon[5, 5];

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    boardAsMatrix[i, j] = board[i, j];
                }
            }

            var anotherMemento = new Memento(boardAsMatrix).Board;

            Assert.AreEqual(memento, anotherMemento);
        }