}
@Test
public void draw() {
Painter painter = mock(Painter.class);
GameGrid grid;
grid = new GameGrid(0, 0, 10, 10);
grid.draw(painter);
verify(painter).drawRect(0, 0, 10, 10);
// Horizontal lines
for (int i = 0; i <= 10; i++) {
verify(painter).drawLine(0, i, 10, i);
}
// Vertical lines
for (int i = 0; i <= 10; i++) {
verify(painter).drawLine(i, 0, i, 10);
}
grid = new GameGrid(0, 0, 3, 7);
grid.draw(painter);
verify(painter).drawRect(0, 0, 3, 7);
// Horizontal lines
for (int i = 0; i <= 7; i++) {
verify(painter, times(1)).drawLine(0, i, 3, i);
}
// Vertical lines
for (int i = 0; i <= 3; i++) {
verify(painter).drawLine(i, 0, i, 7);
}
grid = gameGrid2();
grid.draw(painter);
verify(painter).drawRect(3, 5, 6, 4);
// Horizontal lines
for (int i = 5; i <= 9; i++) {
verify(painter, times(1)).drawLine(3, i, 9, i);
}