Пример #1
0
            public void GliderMovesBoundsUp()
            {
                var initial = new[]
                {
                    1, 1, 1,
                    0, 0, 1,
                    0, 1, 0,
                };
                var step1 = new[]
                {
                    0, 1, 0,
                    0, 1, 1,
                    1, 0, 1,
                    0, 0, 0,
                };

                var universe = new Universe(3, 3);

                universe.SetUniverse(initial);

                universe.Tick();

                UniverseAssert.Equal(step1, universe);
                UniverseAssert.BoundsEqual(-1, -2, 3, 4, universe);
            }
Пример #2
0
            public void IndexerChangesBounds(int x, int y, int minX, int minY, int width, int height)
            {
                var universe = new Universe(3, 3);

                universe[x, y] = CellState.Alive;

                UniverseAssert.BoundsEqual(minX, minY, width, height, universe);
            }
Пример #3
0
            public void GliderMovesBoundsMultipleTimes()
            {
                var initial = new[]
                {
                    0, 1, 0,
                    0, 0, 1,
                    1, 1, 1,
                };
                var step1 = new[]
                {
                    0, 0, 0,
                    1, 0, 1,
                    0, 1, 1,
                    0, 1, 0,
                };
                var step2 = new[]
                {
                    0, 0, 0,
                    0, 0, 1,
                    1, 0, 1,
                    0, 1, 1,
                };
                var step3 = new[]
                {
                    0, 0, 0, 0,
                    0, 1, 0, 0,
                    0, 0, 1, 1,
                    0, 1, 1, 0,
                };

                var universe = new Universe(3, 3);

                universe.SetUniverse(initial);

                universe.Tick();
                UniverseAssert.Equal(step1, universe);
                UniverseAssert.BoundsEqual(-1, -1, 3, 4, universe);

                universe.Tick();
                UniverseAssert.Equal(step2, universe);
                UniverseAssert.BoundsEqual(-1, -1, 3, 4, universe);

                universe.Tick();
                UniverseAssert.Equal(step3, universe);
                UniverseAssert.BoundsEqual(-1, -1, 4, 4, universe);
            }