Skip to content
Snippets Groups Projects
Commit 4450a8e9 authored by Steve McKinnon's avatar Steve McKinnon
Browse files

created tests to check complete box and redraw line

parent 24b230ca
No related branches found
No related merge requests found
......@@ -14,18 +14,39 @@ 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
*/
* A test to check if a box is correctly marked as complete.
* Asserting False after drawing a complete box
*/
@Test
public void testTestSuiteRuns() {
logger.info("Dummy test to show the test suite runs");
assertTrue(true);
public void testForCompleteBox() {
logger.info("Testing the complete box");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(10,10,2);
grid.drawHorizontal(1,1,1);
grid.drawHorizontal(1,2,1);
grid.drawVertical(1,1,1);
grid.drawVertical(2,1,1);
assertFalse(grid.boxComplete(1, 1));
}
// FIXME: You need to write tests for the two known bugs in the code.
/*
* A test to see if a line can be redrawn after it has already been drawn,
* test should throw an exception
*/
@Test
public void testRedrawLineFails() {
logger.info("Testing redrawing a line");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(10,10,2);
grid.drawVertical(5,5,1);
assertThrows(IllegalStateException.class, () -> grid.drawVertical(5, 5, 1));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment