diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1946beda974d180686c65c0259a7b881e9a4eb5a..921e6443fb637ed96c336ea8bd77384d0a6e979e 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -28,4 +28,36 @@ public class DotsAndBoxesGridTest { } // FIXME: You need to write tests for the two known bugs in the code. + @Test + public void testBoxComplete() { + logger.info("Creating a new game"); + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 5, 1); + + logger.info("Drawing three of four box sides"); + grid.drawHorizontal(0,0,1); + grid.drawHorizontal(1, 0, 1); + grid.drawVertical(0, 0, 1); + + assertFalse(grid.boxComplete(0,0)); + + logger.info("Completing the box"); + grid.drawVertical(0, 1, 1); + + assertTrue(grid.boxComplete(0,0)); + } + + @Test + public void testLineDoubleUp() { + logger.info("Creating a new game"); + DotsAndBoxesGrid gridTwo = new DotsAndBoxesGrid(3, 5, 1); + + logger.info("Drawing a horizontal line"); + gridTwo.drawHorizontal(1, 1, 1); + assertThrows(IllegalStateException.class, () -> gridTwo.drawHorizontal(1, 1, 1), "This horizontal line is already taken"); + + logger.info("Drawing a vertical line"); + gridTwo.drawVertical(2, 2, 1); + assertThrows(IllegalStateException.class, () -> gridTwo.drawVertical(2, 2, 1), "This vertical line is already taken"); + } + }