From 3cff0b8d4223132108dfa51a12c56ba3042071ee Mon Sep 17 00:00:00 2001
From: Matthew Thomas <mthoma48@myune.edu.au>
Date: Fri, 23 Jul 2021 15:31:12 -0400
Subject: [PATCH] Initial unit tests for Issue 1 bugs, completeBoxTest and
 gridLineException

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

diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
index 1aac7cc..7631627 100644
--- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
@@ -21,6 +21,7 @@ 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");
@@ -28,4 +29,29 @@ public class DotsAndBoxesGridTest {
     }
 
     // FIXME: You need to write tests for the two known bugs in the code.
+
+    // Test if algorithm for testing whether a box is complete is wrong
+    @Test
+    public void completeBoxTest() {
+        logger.info("Test to see if completion algorithm is working");
+
+        DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4,2,2);
+        // draw a complete square
+        grid.drawHorizontal(1,1,1);
+        grid.drawHorizontal(1,2,1);
+        grid.drawVertical(1,2,1);
+        assertTrue(grid.drawVertical(2,2,1));
+    }
+
+    // Test that DotsAndBoxesGrid currently allows drawing a line on an existing line
+    @Test
+    public void gridLineException() {
+        logger.info("Should not be able to draw a line over an already existing line");
+
+        DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4,2,2);
+        grid.drawHorizontal(1,1,1);
+        // assert error here
+        assertThrows(RuntimeException.class, () -> grid.drawHorizontal(1,1,2), "Line was drawn over another");
+
+    }
 }
-- 
GitLab