Beispiel #1
0
        public void ThrowExceptionIfNumberOfCellsIsTwo()
        {
            Ecosystem ecosystem = new Ecosystem();

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

            GameOfLife gameOfLife = new GameOfLife(ecosystem);

            Assert.Throws <Exception>(() => gameOfLife.Play());
        }
Beispiel #2
0
        public void ReturnNewPatternWhenYouIntroduceABeaconPattern()
        {
            Ecosystem expectedEcosystem = new Ecosystem();

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

            Ecosystem ecosystem = new Ecosystem();

            ecosystem.AddCell(0, 0);
            ecosystem.AddCell(0, 1);
            ecosystem.AddCell(1, 1);
            ecosystem.AddCell(1, 0);
            ecosystem.AddCell(2, 2);
            ecosystem.AddCell(2, 3);
            ecosystem.AddCell(3, 2);
            ecosystem.AddCell(3, 3);

            GameOfLife gameOfLife = new GameOfLife(ecosystem);

            gameOfLife.Play();

            Assert.Equal(expectedEcosystem, ecosystem);
        }
Beispiel #3
0
        public void KeepRevivedCellsWhenYouIntroduceThreeInARow()
        {
            Ecosystem expectedEcosystem = new Ecosystem();

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

            Ecosystem ecosystem = new Ecosystem();

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

            GameOfLife gameOfLife = new GameOfLife(ecosystem);

            gameOfLife.Play();

            Assert.Equal(expectedEcosystem, ecosystem);
        }
Beispiel #4
0
        public void KeepAliveAllCellsWhenFirstGenerationIsASquare()
        {
            Ecosystem expectedEcosystem = new Ecosystem();

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

            Ecosystem ecosystem = new Ecosystem();

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

            GameOfLife gameOfLife = new GameOfLife(ecosystem);

            gameOfLife.Play();

            Assert.Equal(expectedEcosystem, ecosystem);
        }