diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1aac7ccc87bd5620cdcd1db9b008f20a08d50640..4f6190a7d717996629a216e7dbab2fb012eceda5 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -21,11 +21,60 @@ public class DotsAndBoxesGridTest { * * This is a dummy test just to show that the test suite itself runs */ + @Test public void testTestSuiteRuns() { logger.info("Dummy test to show the test suite runs"); assertTrue(true); } + @Test + public void noLinesDrawnTest() { + logger.error("Test whether boxComplete shows false with no lines drawn"); + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2); + assertFalse(grid.boxComplete(0, 0)); + } + + @Test + public void oneLineTest() { + logger.error("Test whether boxComplete shows false with one line on each side drawn"); + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2); + grid.drawHorizontal(0,0,1); + grid.drawVertical(0,0,1); + assertFalse(grid.boxComplete(0, 0)); + } + + @Test + public void completeBoxTest() { + logger.error("Test whether boxComplete shows true with whole box"); + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2); + grid.drawHorizontal(0,0,1); + grid.drawHorizontal(0,1,1); + grid.drawVertical(0,0,1); + grid.drawVertical(1,0,1); + assertTrue(grid.boxComplete(0, 0)); + } + @Test + public void horizontalReDrawTest() { + logger.error("Test whether drawHorizontal throws exception if line is already present"); + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2); + grid.drawHorizontal(0,0,1); + assertThrows(RuntimeException.class, () -> grid.boxComplete(0, 0)); + } + @Test + public void verticalReDrawTest() { + logger.error("Test whether drawHorizontal throws exception if line is already present"); + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2); + grid.drawVertical(0,0,1); + assertThrows(RuntimeException.class, () -> grid.drawVertical(0, 0,1)); + } + + + + + + + + // FIXME: You need to write tests for the two known bugs in the code. }