diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1aac7ccc87bd5620cdcd1db9b008f20a08d50640..f5d0431b3b107646905ff94f1d916fa5160a1dcf 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -28,4 +28,43 @@ public class DotsAndBoxesGridTest { } // 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