public void GameOfLifeMatrixShouldReturnNumberOfLivingNeighbors() { int[,] pattern = new int[4, 5] { { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 } }; IGameOfLifeMatrix matrix = new GameOfLifeMultiArray(5, 4); GameOfLife.InitializeGameOfLife(matrix, pattern); CheckForLivingNeighbors(matrix); // Test the dictionary version matrix = new GameOfLifeHashSet(5, 4); GameOfLife.InitializeGameOfLife(matrix, pattern); CheckForLivingNeighbors(matrix); }
public void MatrixContainInitialzationData() { GameOfLifeMultiArray matrix = new GameOfLifeMultiArray(6, 6); int[,] blinker = new int[5, 5] { { 0, 0, 0, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0 } }; GameOfLife.InitializeGameOfLife(matrix, blinker); for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { Assert.AreEqual(blinker[y, x] == 1, matrix.IsCellAlive(x, y), $"Test of cell {x},{y}"); } } }