예제 #1
0
        public void ClearingGridShouldDecimateAllCells()
        {
            _grid = new Grid(new [,]
                {
                    { true,  false, true,  false, true },
                    { false, true,  false, true,  false }
                });

            _grid.Clear();

            for(var x = 0; x < _grid.Cells.GetLength(0); x++)
                for (var y = 0; y < _grid.Cells.GetLength(1); y++)
                    Assert.That(_grid.Cells[x,y], Is.False);
        }
예제 #2
0
        public void CellsWithThreeNeighborsStayAliveIfAliveOrComeAliveIfDead()
        {
            var testGrid = new Grid(new[,]
                {
                    {true,  false, false},
                    {false, true,  false},
                    {false, true,  true }
                });

            _expected = new Grid(new[,]
                {
                    {false, false, false},
                    {true,  true,  true},
                    {false, true,  true}
                });

            Assert.AreEqual(_expected.Cells, _game.Play(testGrid).Cells);
        }
예제 #3
0
        public void CellsWithFourOrMoreNeighborsDie()
        {
            var testGrid = new Grid(new[,]
                {
                    {false, false, false},
                    {true,  true,  true},
                    {false, true,  true}
                });

            _expected = new Grid(new[,]
                {
                    {false, true,  false},
                    {true,  false, true},
                    {true,  false, true}
                });

            Assert.AreEqual(_expected.Cells, _game.Play(testGrid).Cells);
        }
예제 #4
0
        public void CellsWithFewerThanTwoNeighboursAreDecimated()
        {
            var testGrid = new Grid(new [,]
                {
                    {false, false, false},
                    {false, true,  false},
                    {false, false, true }
                });

            _expected = new Grid(new [,]
                {
                    {false, false, false},
                    {false, false, false},
                    {false, false, false}
                });

            Assert.AreEqual(_expected.Cells, _game.Play(testGrid).Cells);
        }
예제 #5
0
 public void TwoByTwoGridShouldInitializeToTwoByTwo()
 {
     var grid = new Grid(new bool[2, 2]);
     Assert.That(grid.Cells.GetLength(0), Is.EqualTo(2));
     Assert.That(grid.Cells.GetLength(1), Is.EqualTo(2));
 }
예제 #6
0
 public void SetUp()
 {
     _grid = new Grid(new bool[100,100]);
 }
예제 #7
0
        public void CellsWithTwoNeighboursThatAreAliveStayAlive()
        {
            var testGrid = new Grid(new[,]
                {
                    {true,  false, false},
                    {false, true,  false},
                    {false, false, true }
                });

            _expected = new Grid(new[,]
                {
                    {false, false, false},
                    {false, true,  false},
                    {false, false, false}
                });

            Assert.AreEqual(_expected.Cells, _game.Play(testGrid).Cells);
        }