Skip to content
Snippets Groups Projects
Commit 13feb624 authored by Matthew Trippe's avatar Matthew Trippe
Browse files

Created unit tests for CompleteBox and Exception throws on existing line

parent ed41e0cc
No related branches found
No related tags found
No related merge requests found
...@@ -28,4 +28,43 @@ public class DotsAndBoxesGridTest { ...@@ -28,4 +28,43 @@ public class DotsAndBoxesGridTest {
} }
// FIXME: You need to write tests for the two known bugs in the code. // FIXME: You need to write tests for the two known bugs in the code.
@Test
public void testBoxComplete() {
logger.info("This test sets up a test square 10,10,2 and draws a box for player1");
// set up the test box
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(10,10,2);
// draw a test square, player 1
grid.drawHorizontal(0,0,1);
grid.drawHorizontal(0,1,1);
grid.drawVertical(0,0,1);
grid.drawVertical(1,0,1);
assertAll(
// complete box
() -> assertTrue(grid.boxComplete(0,0)),
// incomplete box
() -> assertFalse(grid.boxComplete(1,1))
);
}
@Test
public void testDrawLine() {
logger.info("Dummy test to show the Exception test runs");
// set up the test box
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(10,10,2);
// draw a test line, player 1
grid.drawHorizontal(0,0,1);
grid.drawVertical(0,0,1);
// redraw lines to throw the exceptions
assertThrows(IllegalStateException.class, () -> grid.drawHorizontal(0,0,1));
assertThrows(IllegalStateException.class, () -> grid.drawVertical(0,0,1));
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment