From fb19c627809f1b79567c51cd958f38a939b58e7b Mon Sep 17 00:00:00 2001 From: AlisonB <abryce2@myune.edu.au> Date: Thu, 15 Jul 2021 20:34:56 +1000 Subject: [PATCH] Added unit testing --- .../dotsandboxes/DotsAndBoxesGridTest.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1946bed..be39b0f 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -27,5 +27,36 @@ public class DotsAndBoxesGridTest { assertTrue(true); } - // FIXME: You need to write tests for the two known bugs in the code. + @Test + public void testBoxComplete() { + logger.info("Test to show that box complete runs correctly"); + DotsAndBoxesGrid DaB = new DotsAndBoxesGrid(10, 10, 1); + Assertions.assertEquals(false, DaB.boxComplete(4, 3)); + } + + @Test + public void testdrawHorizontal() { + logger.info("Test to show horizontal lines can only be draw once in the same place"); + DotsAndBoxesGrid DaB = new DotsAndBoxesGrid(10, 10, 1); + DaB.drawHorizontal(4, 2, 1); + Assertions.assertThrows(IllegalStateException.class, () -> { + DaB.drawHorizontal(4,2, 1); + }, "There is already a horizontal line here. "); + + } + + @Test + public void testdrawVertical() { + logger.info("Test to show vertical lines can only be draw once in the same place"); + DotsAndBoxesGrid DaB = new DotsAndBoxesGrid(10, 10, 1); + DaB.drawVertical(4, 2, 1); + Assertions.assertThrows(IllegalStateException.class, () -> { + DaB.drawVertical(4,2, 1); + }, "There is already a vertical line here. "); + } + } + + +// FIXME: You need to write tests for the two known bugs in the code. + -- GitLab