Exemple #1
0
        public void AllNonBombsUncovered_NoneUncovered_ReturnsFalse()
        {
            Minefield minefield = new Minefield(DEFAULT_FIELD_SIZE);

            minefield.AddBombs(DEFAULT_BOMBS);
            Assert.IsFalse(minefield.AllNonBombsUncovered());
        }
Exemple #2
0
        public void UncoverNode_BombUncovered_ReturnsTrue()
        {
            Minefield minefield = new Minefield(DEFAULT_FIELD_SIZE);

            minefield.AddBombs(DEFAULT_FIELD_SIZE * DEFAULT_FIELD_SIZE); // Filling the field with bombs.

            Assert.IsTrue(minefield.UncoverNode(0, 0));
        }
Exemple #3
0
        public void AllNonBombsUncovered_OnlyBombsInField_ReturnsTrue()
        {
            Minefield minefield = new Minefield(DEFAULT_FIELD_SIZE);

            minefield.AddBombs(DEFAULT_FIELD_SIZE * DEFAULT_FIELD_SIZE); // Filling the field with bombs.

            Assert.IsTrue(minefield.AllNonBombsUncovered());
        }
Exemple #4
0
        public void AddBombs_XBombsAdded_XBombsInField()
        {
            Minefield minefield = new Minefield(DEFAULT_FIELD_SIZE);

            minefield.AddBombs(DEFAULT_BOMBS);
            int bombs = 0;

            for (int i = 0; i < DEFAULT_FIELD_SIZE; i++)
            {
                for (int j = 0; j < DEFAULT_FIELD_SIZE; j++)
                {
                    bombs += minefield.UncoverNode(i, j) ? 1 : 0;
                }
            }

            Assert.AreEqual(DEFAULT_BOMBS, bombs);
        }
Exemple #5
0
        public void AddBombs_MoreBombsThanNodesAdded_ThrowsException()
        {
            Minefield minefield = new Minefield(DEFAULT_FIELD_SIZE);

            minefield.AddBombs(DEFAULT_FIELD_SIZE * DEFAULT_FIELD_SIZE + 1);
        }