public void TestGetContainingSquare( [Values(2, 3, 2, 4)] int columns, [Values(2, 2, 3, 4)] int rows) { var pf = new Playfield(columns, rows); for (int c = 0; c < pf.NumCellColumns; c++) { for (int r = 0; r < pf.NumCellRows; r++) { var cell = pf.Cells[c][r]; var ul = pf.GetContainingSquare(cell, Playfield.SquarePosition.UpperLeft); Assert.AreEqual(ul, c >= pf.NumSquareColumns || r >= pf.NumSquareRows ? null : pf.Squares[c][r]); var ll = pf.GetContainingSquare(cell, Playfield.SquarePosition.LowerLeft); Assert.AreEqual(ll, c >= pf.NumSquareColumns || r <= 0 ? null : pf.Squares[c][r - 1]); var ur = pf.GetContainingSquare(cell, Playfield.SquarePosition.UpperRight); Assert.AreEqual(ur, c <= 0 || r >= pf.NumSquareRows ? null : pf.Squares[c - 1][r]); var lr = pf.GetContainingSquare(cell, Playfield.SquarePosition.LowerRight); Assert.AreEqual(lr, c <= 0 || r <= 0 ? null : pf.Squares[c - 1][r - 1]); } } }