From 3068f5da8c2cc00256f2610216c0315274a01620 Mon Sep 17 00:00:00 2001
From: Nathan Reeves <nreeves5@myune.edu.au>
Date: Sun, 25 Jul 2021 13:59:59 +1000
Subject: [PATCH] Committing with unit tests for box completion and line
 already drawn, both fail.

---
 .../dotsandboxes/DotsAndBoxesGridTest.java    | 30 ++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
index 1aac7cc..bca1591 100644
--- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
@@ -3,6 +3,7 @@ package dotsandboxes;
 import org.junit.jupiter.api.*;
 import static org.junit.jupiter.api.Assertions.*;
 import static org.junit.jupiter.api.Assumptions.*;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -28,4 +29,31 @@ public class DotsAndBoxesGridTest {
     }
 
     // FIXME: You need to write tests for the two known bugs in the code.
-}
+    @Test
+    public void testTestingBoxComplete() {
+        logger.info("Test of box completion test");
+        logger.info("Drawing complete box, then asserting incomplete state");
+        DotsAndBoxesGrid g = new DotsAndBoxesGrid(4,4,1);
+        g.drawHorizontal(1,1, 1);
+        g.drawHorizontal(1,2,1);
+        g.drawVertical(1,1,1);
+        g.drawVertical(2,1,1);
+        assertEquals(false,g.boxComplete(1,1));
+    }
+
+    @Test
+    public void testTestingLineDrawn() {
+        logger.info("Test of line already drawn detection");
+        logger.info("Instantiating new grid");
+        DotsAndBoxesGrid h = new DotsAndBoxesGrid(4,4,1);
+        logger.info("Drawing a line to later be duplicated");
+        h.drawHorizontal(1,1,1);
+        logger.info("Drawing line a second time within an assert throws block, expecting and illegal state exception");
+        IllegalStateException thrown = assertThrows(
+                IllegalStateException.class, () -> h.drawHorizontal (1,1,1),
+                "Drawing second horizontal line should have thrown illegal state exception, did not"
+        );
+        assertTrue(thrown.getMessage().contains("IllegalStateException"));
+
+    }
+}
\ No newline at end of file
-- 
GitLab