From b9ff1f22bc60b88d6e4f51edddcb392ea81e8bf7 Mon Sep 17 00:00:00 2001
From: bmcandre <bmcandre@myune.edu.au>
Date: Wed, 2 Aug 2023 15:25:18 +1000
Subject: [PATCH] Unit tests added

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

diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
index 1946bed..136f829 100644
--- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
@@ -27,5 +27,30 @@ public class DotsAndBoxesGridTest {
         assertTrue(true);
     }
 
-    // FIXME: You need to write tests for the two known bugs in the code.
+    @Test
+    public void boxCompleteDetectsCompletedBoxes() {
+        // A grid where we're going to draw a box, and then test whether it's complete
+        DotsAndBoxesGrid case1 = new DotsAndBoxesGrid(5, 5, 2);
+        case1.drawHorizontal(0, 0, 0);
+        case1.drawVertical(0, 0, 1);
+        case1.drawHorizontal(0, 1, 0);
+        case1.drawVertical(1, 0, 1);
+
+        assertTrue(case1.boxComplete(0, 0));
+        assertTrue(case1.boxComplete(1, 1));
+        assertTrue(case1.getHorizontal(0, 0)&&case1.getVertical(0, 0));
+        assertTrue(case1.getHorizontal(1, 0)&&case1.getVertical(1, 0));
+
+    }
+
+    @Test
+    public void drawHorizontalTest() {
+        DotsAndBoxesGrid case1 = new DotsAndBoxesGrid(5, 5, 2);
+        case1.drawHorizontal(0, 0, 0);
+        case1.drawVertical(0, 0, 1);
+        case1.drawHorizontal(0, 1, 0);
+        case1.drawVertical(1, 0, 1);
+
+        assertThrows(RuntimeException.class, () -> {case1.drawHorizontal(0, 0, 0);});
+    }
 }
-- 
GitLab