From fc89506b4ebd25c7a3b8b419affd2721fe37dd04 Mon Sep 17 00:00:00 2001
From: William Billingsley <wbilling@une.edu.au>
Date: Wed, 31 Jul 2024 21:49:20 +1000
Subject: [PATCH] Added test units to detect the errors

---
 .../dotsandboxes/DotsAndBoxesGridTest.java    | 38 +++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
index 1946bed..a5579d4 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.
 }
-- 
GitLab