Esempio n. 1
0
        public void ProcessGeneration_3x3Grid(bool leftTop, bool top, bool rightTop, bool left, bool center, bool right, bool leftBottom, bool bottom, bool rightBottom,
                                              bool expectedLeftTop, bool expectedTop, bool expectedRightTop,
                                              bool expectedLeft, bool expectedCenter, bool expectedRight,
                                              bool expectedLeftBottom, bool expectedBottom, bool expectedRightBottom)
        {
            var grid = new Grid(new Vector(3, 3));
            grid.Cells[0, 0] = new Cell(0, 0, leftTop);
            grid.Cells[0, 1] = new Cell(0, 1, top);
            grid.Cells[0, 2] = new Cell(0, 2, rightTop);
            grid.Cells[1, 0] = new Cell(1, 0, left);
            grid.Cells[1, 1] = new Cell(1, 1, center);
            grid.Cells[1, 2] = new Cell(1, 2, right);
            grid.Cells[2, 0] = new Cell(2, 0, leftBottom);
            grid.Cells[2, 1] = new Cell(2, 1, bottom);
            grid.Cells[2, 2] = new Cell(2, 2, rightBottom);

            grid.ProcessGeneration();

            Assert.AreEqual(expectedLeftTop, grid.Cells[0, 0].IsAlive);
            Assert.AreEqual(expectedTop, grid.Cells[0, 1].IsAlive);
            Assert.AreEqual(expectedRightTop, grid.Cells[0, 2].IsAlive);
            Assert.AreEqual(expectedLeft, grid.Cells[1, 0].IsAlive);
            Assert.AreEqual(expectedCenter, grid.Cells[1, 1].IsAlive);
            Assert.AreEqual(expectedRight, grid.Cells[1, 2].IsAlive);
            Assert.AreEqual(expectedLeftBottom, grid.Cells[2, 0].IsAlive);
            Assert.AreEqual(expectedBottom, grid.Cells[2, 1].IsAlive);
            Assert.AreEqual(expectedRightBottom, grid.Cells[2, 2].IsAlive);
        }