diff --git a/build.gradle b/build.gradle index a64642b1797414bb041f02d82b739718fddbaa6f..e067df36ed54c1f6d724426dfae62df913fdfbb2 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ task fatJar(type: Jar) { manifest { attributes 'Main-Class': 'dotsandboxes.Main' } - baseName = 'executable-jar' + archiveBaseName = 'executable-jar' duplicatesStrategy = DuplicatesStrategy.EXCLUDE from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } with jar diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1946beda974d180686c65c0259a7b881e9a4eb5a..f93614f34fc5c63943b1f2e277f62a3aa2357939 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -4,6 +4,8 @@ import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assumptions.*; +import java.beans.Transient; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,17 +17,47 @@ public class DotsAndBoxesGridTest { 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 + * Code to test that boxComplete returns true for boxes that are complete + */ + @Test + public void boxCompleteDetectsCompletedBoxes(){ + DotsAndBoxesGrid tGrid = new DotsAndBoxesGrid(5, 5, 2); + tGrid.drawHorizontal(0, 0, 0); + tGrid.drawHorizontal(0, 1, 0); + tGrid.drawVertical(0, 0, 0); + tGrid.drawVertical(1, 0, 0); + assertTrue(tGrid.boxComplete(0, 0)); + } + + /* + * Code to test that boxComplete returns false for boxes that are not complete */ @Test - public void testTestSuiteRuns() { - logger.info("Dummy test to show the test suite runs"); - assertTrue(true); + public void boxCompleteDetectsIncompleteBoxes(){ + DotsAndBoxesGrid tBoxesGrid = new DotsAndBoxesGrid(5,5 , 2); + assertFalse(tBoxesGrid.boxComplete(0, 0)); + tBoxesGrid.drawHorizontal(0, 0, 0); + assertFalse(tBoxesGrid.boxComplete(0, 0)); + tBoxesGrid.drawHorizontal(0, 1, 0); + assertFalse(tBoxesGrid.boxComplete(0, 0)); + tBoxesGrid.drawVertical(0, 0, 0); + assertFalse(tBoxesGrid.boxComplete(0, 0)); + } + /* + * Code to test if a line is drawn on top of an existing line is detected + */ + @Test + public void drawMethodsDetectRedrawnLines(){ + DotsAndBoxesGrid tGrid = new DotsAndBoxesGrid(5, 5, 2); + tGrid.drawHorizontal(0, 0, 0); + assertThrows(IllegalStateException.class, () -> { + tGrid.drawHorizontal(0, 0, 0); + }); - // FIXME: You need to write tests for the two known bugs in the code. + tGrid.drawVertical(0, 0, 0); + assertThrows(IllegalStateException.class, () -> { + tGrid.drawVertical(0, 0, 0); + }); + } }