示例#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);
        }