Ejemplo n.º 1
0
        public void DeadCellWithZeroLivingNeighbourTest()
        {
            cgolTest = new ConwayGameOfLife(2, 2);
            cgolTest.CurrentIteration[1, 1] = cgolTest.livingCellRep;
            cgolTest.RuleImplementation(1, 1, cgolTest.LivingNeighbourCounter(1, 1));
            Array.Copy(cgolTest.NextIteration, cgolTest.CurrentIteration, cgolTest.BoardWidth * cgolTest.BoardHeight);

            var result = cgolTest.LivingNeighbourCounter(0, 0);

            Assert.IsTrue(result == 0);
        }
Ejemplo n.º 2
0
        public void DeadCellWithThreeLivingNeighboursTest()
        {
            cgolTest = new ConwayGameOfLife(3, 3);
            cgolTest.CurrentIteration[1, 1] = cgolTest.deadCellRep;
            cgolTest.CurrentIteration[0, 1] = cgolTest.livingCellRep;
            cgolTest.CurrentIteration[0, 2] = cgolTest.livingCellRep;
            cgolTest.CurrentIteration[1, 2] = cgolTest.livingCellRep;
            Array.Copy(cgolTest.CurrentIteration, cgolTest.NextIteration, cgolTest.BoardWidth * cgolTest.BoardHeight);
            cgolTest.RuleImplementation(1, 1, cgolTest.LivingNeighbourCounter(1, 1));
            Array.Copy(cgolTest.NextIteration, cgolTest.CurrentIteration, cgolTest.BoardWidth * cgolTest.BoardHeight);

            var result = cgolTest.LivingNeighbourCounter(1, 1);

            Assert.IsTrue(cgolTest.CurrentIteration[1, 1] == cgolTest.livingCellRep);
        }