Exemplo n.º 1
0
        public void KillACellWithoutNeighbors()
        {
            Ecosystem expectedEcosystem = new Ecosystem();

            Ecosystem ecosystem = new Ecosystem();

            ecosystem.AddCell(0, 0);
            GameOfLife gameOfLife = new GameOfLife(ecosystem);

            gameOfLife.Evolve();

            Assert.Equal(expectedEcosystem, ecosystem);
        }
Exemplo n.º 2
0
        public void KeepAliveMiddleCellWhenTheres3CellsInDiagonal()
        {
            Ecosystem expectedEcosystem = new Ecosystem();

            expectedEcosystem.AddCell(1, 1);

            Ecosystem ecosystem = new Ecosystem();

            ecosystem.AddCell(0, 0);
            ecosystem.AddCell(1, 1);
            ecosystem.AddCell(2, 2);
            GameOfLife gameOfLife = new GameOfLife(ecosystem);

            gameOfLife.Evolve();

            Assert.Equal(expectedEcosystem, ecosystem);
        }
Exemplo n.º 3
0
        public void ReviveACellWhenTheres3CellsNextToIt()
        {
            Ecosystem expectedEcosystem = new Ecosystem();

            expectedEcosystem.AddCell(0, 0);

            expectedEcosystem.AddCell(1, 1);
            expectedEcosystem.AddCell(1, 0);
            expectedEcosystem.AddCell(0, 1);

            Ecosystem ecosystem = new Ecosystem();

            ecosystem.AddCell(0, 0);
            ecosystem.AddCell(1, 0);
            ecosystem.AddCell(1, 1);
            GameOfLife gameOfLife = new GameOfLife(ecosystem);

            gameOfLife.Evolve();

            Assert.Equal(expectedEcosystem, ecosystem);
        }
Exemplo n.º 4
0
        public void KillCellWithMoreThan3Neighbors()
        {
            Ecosystem expectedEcosystem = new Ecosystem();

            expectedEcosystem.AddCell(1, 0);
            expectedEcosystem.AddCell(0, 1);
            expectedEcosystem.AddCell(2, 1);
            expectedEcosystem.AddCell(1, 2);


            Ecosystem ecosystem = new Ecosystem();

            ecosystem.AddCell(0, 0);
            ecosystem.AddCell(0, 2);
            ecosystem.AddCell(1, 1);
            ecosystem.AddCell(2, 0);
            ecosystem.AddCell(2, 2);
            GameOfLife gameOfLife = new GameOfLife(ecosystem);

            gameOfLife.Evolve();

            Assert.Equal(expectedEcosystem, ecosystem);
        }