Skip to content
Snippets Groups Projects
Commit 5d5537a5 authored by Camillie Ashmore's avatar Camillie Ashmore
Browse files

Created unit tests for boxComplete, drawHorizontal and drawVertical methods

parent baa3e4e8
Branches
No related merge requests found
...@@ -28,4 +28,36 @@ public class DotsAndBoxesGridTest { ...@@ -28,4 +28,36 @@ public class DotsAndBoxesGridTest {
} }
// FIXME: You need to write tests for the two known bugs in the code. // FIXME: You need to write tests for the two known bugs in the code.
@Test
public void testBoxComplete() {
logger.info("Creating a new game");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 5, 1);
logger.info("Drawing three of four box sides");
grid.drawHorizontal(0,0,1);
grid.drawHorizontal(1, 0, 1);
grid.drawVertical(0, 0, 1);
assertFalse(grid.boxComplete(0,0));
logger.info("Completing the box");
grid.drawVertical(0, 1, 1);
assertTrue(grid.boxComplete(0,0));
}
@Test
public void testLineDoubleUp() {
logger.info("Creating a new game");
DotsAndBoxesGrid gridTwo = new DotsAndBoxesGrid(3, 5, 1);
logger.info("Drawing a horizontal line");
gridTwo.drawHorizontal(1, 1, 1);
assertThrows(IllegalStateException.class, () -> gridTwo.drawHorizontal(1, 1, 1), "This horizontal line is already taken");
logger.info("Drawing a vertical line");
gridTwo.drawVertical(2, 2, 1);
assertThrows(IllegalStateException.class, () -> gridTwo.drawVertical(2, 2, 1), "This vertical line is already taken");
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment