Commit de4783d4 authored by Martin Schreiber's avatar Martin Schreiber
Browse files

added unit tests for issue #1

parent 9dcdc67e
......@@ -21,11 +21,60 @@ public class DotsAndBoxesGridTest {
*
* 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 noLinesDrawnTest() {
logger.error("Test whether boxComplete shows false with no lines drawn");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2);
assertFalse(grid.boxComplete(0, 0));
}
@Test
public void oneLineTest() {
logger.error("Test whether boxComplete shows false with one line on each side drawn");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2);
grid.drawHorizontal(0,0,1);
grid.drawVertical(0,0,1);
assertFalse(grid.boxComplete(0, 0));
}
@Test
public void completeBoxTest() {
logger.error("Test whether boxComplete shows true with whole box");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2);
grid.drawHorizontal(0,0,1);
grid.drawHorizontal(0,1,1);
grid.drawVertical(0,0,1);
grid.drawVertical(1,0,1);
assertTrue(grid.boxComplete(0, 0));
}
@Test
public void horizontalReDrawTest() {
logger.error("Test whether drawHorizontal throws exception if line is already present");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2);
grid.drawHorizontal(0,0,1);
assertThrows(RuntimeException.class, () -> grid.boxComplete(0, 0));
}
@Test
public void verticalReDrawTest() {
logger.error("Test whether drawHorizontal throws exception if line is already present");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2);
grid.drawVertical(0,0,1);
assertThrows(RuntimeException.class, () -> grid.drawVertical(0, 0,1));
}
// FIXME: You need to write tests for the two known bugs in the code.
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment