diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 5244dbb129eb1d6d7bc29656ba6cee6861a75568..e1c1e5ef1a4bcc43370caf7713a7424558b4a733 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -1,35 +1,25 @@ package dotsandboxes; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; -import static org.junit.jupiter.api.Assumptions.*; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class DotsAndBoxesGridTest { - /* - * Because Test classes are classes, they can have fields, and can have static fields. - * This field is a logger. Loggers are like a more advanced println, for writing messages out to the console or a log file. - */ private static final Logger logger = LogManager.getLogger(DotsAndBoxesGridTest.class); - /* - * Tests are functions that have an @Test annotation before them. - * The typical format of a test is that it contains some code that does something, and then one - * or more assertions to check that a condition holds. - * - * 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"); assertTrue(true); } + @Test public void testSquareCompletion() { logger.info("Testing if square completion detection is working"); - DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3); + + // Initialize the grid with dimensions and number of players + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2); // Simulate drawing lines to complete a square at (0,0) grid.drawHorizontal(0, 0, 1); @@ -37,15 +27,17 @@ public class DotsAndBoxesGridTest { grid.drawHorizontal(0, 1, 1); grid.drawVertical(1, 0, 1); - // The square at (0,0) should be complete - assertTrue(grid.isSquareComplete(0, 0), "Square at (0,0) should be complete"); + // Check if the square at (0,0) is complete + assertTrue(grid.boxComplete(0, 0), "Square at (0,0) should be complete"); } @Test public void testDrawingLineTwiceThrowsException() { logger.info("Testing if drawing a line twice throws an IllegalStateException"); - DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3); - + + // Initialize the grid with dimensions and number of players + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2); + // Simulate drawing a horizontal line grid.drawHorizontal(0, 0, 1); @@ -53,3 +45,4 @@ public class DotsAndBoxesGridTest { assertThrows(IllegalStateException.class, () -> grid.drawHorizontal(0, 0, 1)); } } +