diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1946beda974d180686c65c0259a7b881e9a4eb5a..a5579d49664db032656ef7b9eed02c4f4aae56b8 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -27,5 +27,43 @@ public class DotsAndBoxesGridTest { assertTrue(true); } + @Test + public void testBoxComplete(){ + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4,4,2); + + //Drawing lines + grid.drawHorizontal(1,1,1); + grid.drawHorizontal(1,2,1); + grid.drawVertical(1,1,1); + grid.drawVertical(2,1,1); + + //The box + assertTrue(grid.BoxComplete(1, 1)); + } + + @Test + public void testDrawAlreadyDrawnLine() { + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 4, 2); + + // Drawing a horizontal line at (1, 1) + grid.drawHorizontal(1, 1, 1); + + // Attempting to draw the same horizontal line again should throw an IllegalStateException + Exception exception = assertThrows(IllegalStateException.class, () -> { + grid.drawHorizontal(1, 1, 1); + }); + assertEquals("Horizontal line at (1, 1) is already drawn.", exception.getMessage()); + + // Drawing a vertical line at (1, 1) + grid.drawVertical(1, 1, 1); + + // Attempting to draw the same vertical line again should throw an IllegalStateException + exception = assertThrows(IllegalStateException.class, () -> { + grid.drawVertical(1, 1, 1); + }); + assertEquals("Vertical line at (1, 1) is already drawn.", exception.getMessage()); + + } + // FIXME: You need to write tests for the two known bugs in the code. }