Exemplo n.º 1
0
        public void TestFillWithRandomMines_AreMinesOnRandomPositionsEachTime()
        {
            Field gameField = new Field();

            gameField.FillWithRandomMines();
            string[,] firstMatrix = gameField.Matrix;

            gameField.Initialize();
            gameField.FillWithRandomMines();
            string[,] secondMatrix = gameField.Matrix;

            bool areDifferent = false;
            for (int i = 0; i < gameField.Rows; i++)
            {
                for (int j = 0; j < gameField.Cols; j++)
                {
                    if (firstMatrix[i, j] != secondMatrix[i, j])
                    {
                        areDifferent = true;
                    }
                }
            }

            Assert.AreEqual(true, areDifferent);
        }
Exemplo n.º 2
0
        public void TestSymbolsWithoutMines()
        {
            Field mineFieldTest = new Minesweeper.Field(5, 10, 15);
            mineFieldTest.Initialize();
            Cell[,] testMineFiled = mineFieldTest.MineField;

            string expectedstarSymbol = string.Empty;
            int counter = 0;

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (testMineFiled[i, j].Value == expectedstarSymbol)
                    {
                        counter++;
                    }
                }
            }

            Assert.AreEqual(35, counter);
        }
Exemplo n.º 3
0
        public void TestNegativeEmprySymbol()
        {
            Field mineFieldTest = new Minesweeper.Field(5, 10, 15);
            mineFieldTest.Initialize();
            Cell[,] testMineFiled = mineFieldTest.MineField;

            string expectedEmptySymbol = string.Empty;
            string expectedstarSymbol = "*";
            int counter = 0;

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if ((testMineFiled[i, j].Value != expectedstarSymbol) &&
                        (testMineFiled[i, j].Value != expectedEmptySymbol))
                    {
                        counter++;
                    }
                }
            }

            Assert.AreEqual(0, counter);
        }
Exemplo n.º 4
0
        public void TestInitialize_IsMatrixInitialized()
        {
            Field gameField = new Field();

            gameField.FillWithRandomMines();
            gameField.Initialize();

            bool isInitialized = true;

            for (int i = 0; i < gameField.Rows; i++)
            {
                for (int j = 0; j < gameField.Cols; j++)
                {
                    if (gameField.Matrix[i, j] != string.Empty)
                    {
                        isInitialized = false;
                        break;
                    }
                }
            }

            Assert.AreEqual(true, isInitialized);
        }