From ebc20df69b879199ea7f9286d825e418f957b2e8 Mon Sep 17 00:00:00 2001 From: summerhenson Date: Fri, 7 Jun 2024 15:15:38 -0400 Subject: [PATCH] Start first Clashing Orbit contradiction rule test --- .../ClashingOrbitContradictionRuleTest.java | 58 +++++++++++++++++++ .../DirectlyAdjacentCenter | 40 +++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 src/test/java/puzzles/starbattle/rules/ClashingOrbitContradictionRuleTest.java create mode 100644 src/test/resources/puzzles/starbattle.rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter diff --git a/src/test/java/puzzles/starbattle/rules/ClashingOrbitContradictionRuleTest.java b/src/test/java/puzzles/starbattle/rules/ClashingOrbitContradictionRuleTest.java new file mode 100644 index 000000000..9dd2abb06 --- /dev/null +++ b/src/test/java/puzzles/starbattle/rules/ClashingOrbitContradictionRuleTest.java @@ -0,0 +1,58 @@ +package puzzles.starbattle.rules; + +import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard; +import edu.rpi.legup.puzzle.starbattle.rules.ClashingOrbitContradictionRule; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.starbattle.StarBattle; +import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; +import edu.rpi.legup.puzzle.starbattle.StarBattleCell; +import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; +import edu.rpi.legup.save.InvalidFileFormatException; +import java.awt.*; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class ClashingOrbitContradictionRuleTest { + + private static final ClashingOrbitContradictionRule RULE = new ClashingOrbitContradictionRule(); + private static StarBattle starBattle; + + @BeforeClass + public static void setUp() { + MockGameBoardFacade.getInstance(); + starBattle = new StarBattle(); + } + + /*Tests the Clashing Orbit contradiction rule*/ + @Test + public void ClashingOrbitContradictionRule_DirectlyAdjacentCenter() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle.rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,1); + StarBattleCell cell2 = board.getCell(2,1); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } +} diff --git a/src/test/resources/puzzles/starbattle.rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter b/src/test/resources/puzzles/starbattle.rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter new file mode 100644 index 000000000..5e37c9eca --- /dev/null +++ b/src/test/resources/puzzles/starbattle.rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file