public void TestGridConstructor() { SudokuGrid testGrid = new SudokuGrid(testDimension1, testSymbols1, testPuzzle1); for (int i = 0; i < testDimension1; i++) { SudokuGridComponent row = testGrid.GetRow(i); SudokuGridComponent column = testGrid.GetColumn(i); SudokuGridComponent box = testGrid.GetBox(i); for (int j = 0; j < testDimension1; j++) { Assert.AreEqual(testPuzzle1[i][j * 2], row[j].Value); Assert.AreEqual(testPuzzle1[j][i * 2], column[j].Value); int r = 3 * (i / 3) + (j / 3); int c = ((j % 3) + ((i % 3) * 3)) * 2; Assert.AreEqual(testPuzzle1[r][c], box[j].Value); } } for (int col = 0; col < testDimension1; col++) { SudokuGridComponent column = testGrid.GetRow(col); for (int index = 0; index < testDimension1; index++) { } } SudokuGrid invalidGrid = null; try { invalidGrid = new SudokuGrid(testInvalidDimension, testSymbols1, testPuzzle1); Assert.Fail(); } catch (ArgumentException arg) { Assert.AreEqual("Dimension of the grid must be a perfect square", arg.Message); } Assert.IsNull(invalidGrid); }