コード例 #1
0
        public void neighboursCounterTest()  //testujemy zwykły warunek - pole jest w środku tablicy
        {
            OneFieldInMapForLifeGame a = new OneFieldInMapForLifeGame();

            int[,] tab = new int[, ] {
                { 0, 1, 0, 1 }, { 1, 0, 0, 1 }, { 1, 1, 0, 0 }, { 0, 1, 0, 0 }
            };
            int countN1 = a.NeighboursCounter(tab, 1, 2);

            Assert.AreEqual(countN1, 4);
        }
コード例 #2
0
        public void neighboursCounter3Test() //testujemy warunek brzegowy malej tablicy - pole jest na skraju tablicy
        {
            OneFieldInMapForLifeGame a = new OneFieldInMapForLifeGame();

            int[,] tab = new int[, ] {
                { 1, 1 }, { 0, 0 }
            };
            int countN1 = a.NeighboursCounter(tab, 0, 1);

            Assert.AreEqual(countN1, 2);
        }
コード例 #3
0
        public void checkIfFieldIsAliveTest()
        {
            OneFieldInMapForLifeGame a = new OneFieldInMapForLifeGame();

            int[,] tab = new int[, ] {
                { 1, 1 }, { 0, 0 }
            };

            a.CheckIfFieldIsAlive(ref tab);
            int c = 0;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    c += tab[i, j];
                }
            }
            Assert.AreEqual(2, c);
        }