Puzzle { public Integer getNumber(Point point) throws IllegalArgumentException { AssertValidIndexes(point); return Numbers[point.x][point.y]; } Puzzle();   Puzzle(Puzzle toCopy);  Puzzle(Integer[][] problem); void setNumber(Point point, Integer value); Integer getNumber(Point point); static final int SIZE; }
@Test(expected = IllegalArgumentException.class) public void InvalidRow_GetNumber_IllegalArgumentExceptionThrown() { Puzzle sut = new Puzzle(); Point invalidPoint = new Point(0, Puzzle.SIZE + 1); sut.getNumber(invalidPoint); }
@Test public void Valid2dArray_PassedToCtor_AllPointsMatch() { Integer[][] valid2dArray = new Integer[9][9]; valid2dArray[1][5] = 5; valid2dArray[3][6] = 7; valid2dArray[2][7] = 8; Puzzle sut = new Puzzle(valid2dArray); for (int x = 0; x < Puzzle.SIZE; x++) { for (int y = 0; y < Puzzle.SIZE; y++) { Point currentPoint = new Point(x, y); Assert.assertEquals(valid2dArray[currentPoint.x][currentPoint.y], sut.getNumber(currentPoint)); } } }
@Test(expected = IllegalArgumentException.class) public void InvalidCol_GetNumber_IllegalArgumentExceptionThrown() { Puzzle sut = new Puzzle(); Point invalidPoint = new Point(Puzzle.SIZE + 1, 0); sut.getNumber(invalidPoint); }