Exemple #1
0
        private static void CreateAndInitializeFivexFiveGridForBlinkerOscillatorPattern()
        {
            FivexFiveGridForBlinkerOscillatorPattern = new Grid(5, 5);

            for (int rowIndex = 0; rowIndex < 5; rowIndex++)
            {
                for (int colIndex = 0; colIndex < 5; colIndex++)
                {
                    var cell = new Cell { RowIndex = rowIndex, ColIndex = colIndex, IsAlive = false };
                    FivexFiveGridForBlinkerOscillatorPattern.AddCell(cell);
                }
            }

            FivexFiveGridForBlinkerOscillatorPattern.GetCellByIndex(2, 1).IsAlive = true;
            FivexFiveGridForBlinkerOscillatorPattern.GetCellByIndex(2, 2).IsAlive = true;
            FivexFiveGridForBlinkerOscillatorPattern.GetCellByIndex(2, 3).IsAlive = true;
        }
Exemple #2
0
        private static void CreateAndInitializeSixxSixGridForToadOscillatorPattern()
        {
            SixxSixGridForToadOscillatorPattern = new Grid(6, 6);

            for (int rowIndex = 0; rowIndex < 6; rowIndex++)
            {
                for (int colIndex = 0; colIndex < 6; colIndex++)
                {
                    var cell = new Cell { RowIndex = rowIndex, ColIndex = colIndex, IsAlive = false };
                    SixxSixGridForToadOscillatorPattern.AddCell(cell);
                }
            }

            SixxSixGridForToadOscillatorPattern.GetCellByIndex(2, 2).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(2, 3).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(2, 4).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(3, 1).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(3, 2).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(3, 3).IsAlive = true;
        }
Exemple #3
0
        public void Test_GetCellByIndex_ValidCellIsAdded_ReturnsSameCellAddedUsingAddCell()
        {
            var grid = new Grid(4, 4);
            var cell = new Cell
            {
                RowIndex = 2,
                ColIndex = 2
            };

            grid.AddCell(cell);

            var returnedCell = grid.GetCellByIndex(2, 2);

            Assert.That(returnedCell, Is.EqualTo(cell),
                        "Cell added using AddCell and cell retrieved using GetCellByIndex should be same");
        }
Exemple #4
0
        public void Test_GetCellByIndex_RowIndexEqualToFour_ThrowsArgumentOutOfRangeException()
        {
            var grid = new Grid(4, 4);
            var cell = new Cell
            {
                RowIndex = 1,
                ColIndex = 1
            };
            grid.AddCell(cell);

            Assert.Throws<ArgumentOutOfRangeException>(() => grid.GetCellByIndex(4,1),
                                                 "ArgumentOutOfRangeException should be thrown");
        }
Exemple #5
0
        public void Test_GetCellByIndex_CellIsNotAddedAtSpecifiedIndex_ReturnsNullCell()
        {
            var grid = new Grid(4, 4);

            var returnedCell = grid.GetCellByIndex(2,2);

            Assert.That(returnedCell, Is.Null, "Cell retrieved should have been null");
        }