Skip to content
Snippets Groups Projects
Commit 3a48c12e authored by Matt Ralston's avatar Matt Ralston
Browse files

Added unit tests

parent 5da13ec9
No related branches found
No related tags found
No related merge requests found
......@@ -27,5 +27,34 @@ public class DotsAndBoxesGridTest {
assertTrue(true);
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public void boxCompleteDetectsCompletedBoxes() {
logger.info("Test to show that boxComplete returns true if all sides have been drawn");
DotsAndBoxesGrid case1 = new DotsAndBoxesGrid(4,4,1);
case1.drawHorizontal(0,0,0);
case1.drawVertical(0,0,1);
case1.drawHorizontal(0,1,0);
case1.drawVertical(1,0,1);
assertTrue(case1.boxComplete(0,0));
}
@Test
public void boxCompleteDetectsIncompleteBoxes() {
logger.info("Test to show that boxComplete returns false if not all sides have been drawn");
DotsAndBoxesGrid case1 = new DotsAndBoxesGrid(4,4,1);
case1.drawHorizontal(0,0,0);
case1.drawVertical(0,0,1);
case1.drawHorizontal(0,1,0);
assertFalse(case1.boxComplete(0,0));
}
@Test
public void drawMethodsDetectRedrawnLines() {
logger.info("Test to show that drawHorizontal throws an exception if the line was already drawn");
DotsAndBoxesGrid case1 = new DotsAndBoxesGrid(4,4,1);
case1.drawHorizontal(0,0,0);
assertThrows(IllegalStateException.class, () -> {
case1.drawHorizontal(0,0,0);
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment