From bc6c17ab09c4db040ce7276f5c871f213d6334ef Mon Sep 17 00:00:00 2001 From: Krishkumar Patel <kpatel9@myune.edu.au> Date: Fri, 18 Aug 2023 01:05:58 +1000 Subject: [PATCH] Added two more test methods that tests if drawing a horizontal line or vertical line on top of another would throw an IllegalArgumentException error. Both test methods failed. --- .../dotsandboxes/DotsAndBoxesGridTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 9a1ece8..ef0170c 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -38,4 +38,30 @@ public class DotsAndBoxesGridTest { grid.drawHorizontal(0, 0, 1); assertEquals(false, grid.boxComplete(0, 0)); } + + /** This test method tests if the drawHorizontal method in DotsAndBoxesGrid.java class returns an + * IllegalArgumentException error when the user tries to draw a horizontal line on top of another + * (on top of an existing line). */ + @DisplayName("Fails to throw an exception when attempting to draw a horizontal line on top of another") + @Test + public void testRedrawingTheLineHoriz() { + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 3, 2); + grid.drawHorizontal(1, 1, 1); + assertThrows(IllegalArgumentException.class, () -> { + grid.drawHorizontal(1, 1, 1); + }); + } + + /** This tests if the drawVertical method in DotsAndBoxesGrid.java class returns an + * IllegalArgumentException error when the user tries to draw a vertical line on top + * of another. */ + @DisplayName("Fails to throw an exception when attempting to draw a Vertical line on top of another") + @Test + public void testRedrawingTheLineVerti() { + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 3, 2); + grid.drawVertical(0, 1, 1); + assertThrows(IllegalArgumentException.class, () -> { + grid.drawVertical(0, 1, 1); + }); + } } -- GitLab