summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java35
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java38
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java42
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java52
4 files changed, 167 insertions, 0 deletions
diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java
new file mode 100644
index 00000000..fdc4467e
--- /dev/null
+++ b/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java
@@ -0,0 +1,35 @@
+package org.luxons.sevenwonders.game.effects;
+
+import org.junit.experimental.theories.DataPoints;
+import org.junit.experimental.theories.Theories;
+import org.junit.experimental.theories.Theory;
+import org.junit.runner.RunWith;
+import org.luxons.sevenwonders.game.boards.Board;
+import org.luxons.sevenwonders.game.resources.ResourceType;
+import org.luxons.sevenwonders.game.test.TestUtils;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Theories.class)
+public class GoldIncreaseTest {
+
+ @DataPoints
+ public static int[] goldAmounts() {
+ return new int[]{-5, -1, 0, 1, 2, 5, 10};
+ }
+
+ @DataPoints
+ public static ResourceType[] resourceTypes() {
+ return ResourceType.values();
+ }
+
+ @Theory
+ public void apply_increaseGoldWithRightAmount(int initialAmount, int goldIncreaseAmount, ResourceType type) {
+ Board board = TestUtils.createBoard(type, initialAmount);
+ GoldIncrease goldIncrease = new GoldIncrease(goldIncreaseAmount);
+
+ goldIncrease.apply(board, null, null);
+
+ assertEquals(initialAmount + goldIncreaseAmount, board.getGold());
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java
new file mode 100644
index 00000000..b5c9a2ee
--- /dev/null
+++ b/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java
@@ -0,0 +1,38 @@
+package org.luxons.sevenwonders.game.effects;
+
+import org.junit.experimental.theories.DataPoints;
+import org.junit.experimental.theories.Theories;
+import org.junit.experimental.theories.Theory;
+import org.junit.runner.RunWith;
+import org.luxons.sevenwonders.game.boards.Board;
+import org.luxons.sevenwonders.game.resources.ResourceType;
+import org.luxons.sevenwonders.game.test.TestUtils;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Theories.class)
+public class MilitaryReinforcementsTest {
+
+ @DataPoints
+ public static int[] shieldCounts() {
+ return new int[]{0, 1, 2, 3, 5};
+ }
+
+ @DataPoints
+ public static ResourceType[] resourceTypes() {
+ return ResourceType.values();
+ }
+
+ @Theory
+ public void apply_increaseGoldWithRightAmount(int initialShields, int additionalShields, ResourceType type) {
+ Board board = TestUtils.createBoard(type);
+ board.setNbWarSymbols(initialShields);
+
+ MilitaryReinforcements reinforcements = new MilitaryReinforcements(additionalShields);
+
+ reinforcements.apply(board, null, null);
+
+ assertEquals(initialShields + additionalShields, board.getNbWarSymbols());
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java
new file mode 100644
index 00000000..d8ecf3ad
--- /dev/null
+++ b/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java
@@ -0,0 +1,42 @@
+package org.luxons.sevenwonders.game.effects;
+
+import org.junit.experimental.theories.DataPoints;
+import org.junit.experimental.theories.Theories;
+import org.junit.experimental.theories.Theory;
+import org.junit.runner.RunWith;
+import org.luxons.sevenwonders.game.boards.Board;
+import org.luxons.sevenwonders.game.resources.ResourceType;
+import org.luxons.sevenwonders.game.resources.Resources;
+import org.luxons.sevenwonders.game.test.TestUtils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Theories.class)
+public class ProductionIncreaseTest {
+
+ @DataPoints
+ public static ResourceType[] resourceTypes() {
+ return ResourceType.values();
+ }
+
+ private static ProductionIncrease createProductionIncrease(ResourceType... types) {
+ ProductionIncrease effect = new ProductionIncrease();
+ effect.getProduction().addAll(TestUtils.createFixedProduction(types));
+ return effect;
+ }
+
+ @Theory
+ public void apply_boardContainsAddedResourceType(ResourceType initialType, ResourceType addedType, ResourceType extraType) {
+ Board board = TestUtils.createBoard(initialType);
+ ProductionIncrease effect = createProductionIncrease(addedType);
+
+ effect.apply(board, null, null);
+
+ Resources resources = TestUtils.createResources(initialType, addedType);
+ assertTrue(board.getProduction().contains(resources));
+
+ Resources moreResources = TestUtils.createResources(initialType, addedType, extraType);
+ assertFalse(board.getProduction().contains(moreResources));
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
new file mode 100644
index 00000000..1eebd3e4
--- /dev/null
+++ b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
@@ -0,0 +1,52 @@
+package org.luxons.sevenwonders.game.test;
+
+import org.luxons.sevenwonders.game.Settings;
+import org.luxons.sevenwonders.game.boards.Board;
+import org.luxons.sevenwonders.game.resources.Production;
+import org.luxons.sevenwonders.game.resources.ResourceType;
+import org.luxons.sevenwonders.game.resources.Resources;
+import org.luxons.sevenwonders.game.wonders.Wonder;
+
+public class TestUtils {
+
+ public static Board createBoard(ResourceType initialResource) {
+ Settings settings = new Settings();
+ Wonder wonder = new Wonder("Test Wonder " + initialResource.getSymbol(), initialResource);
+ return new Board(wonder, settings);
+ }
+
+ public static Board createBoard(ResourceType initialResource, ResourceType... production) {
+ Board board = createBoard(initialResource);
+ board.getProduction().addAll(createFixedProduction(production));
+ return board;
+ }
+
+ public static Board createBoard(ResourceType initialResource, int gold, ResourceType... production) {
+ Board board = createBoard(initialResource, production);
+ board.setGold(gold);
+ return board;
+ }
+
+ public static Wonder createWonder() {
+ return createWonder(ResourceType.WOOD);
+ }
+
+ public static Wonder createWonder(ResourceType initialResource) {
+ return new Wonder("Test Wonder " + initialResource.getSymbol(), initialResource);
+ }
+
+ public static Production createFixedProduction(ResourceType... producedTypes) {
+ Production production = new Production();
+ Resources fixedProducedResources = production.getFixedResources();
+ fixedProducedResources.addAll(createResources(producedTypes));
+ return production;
+ }
+
+ public static Resources createResources(ResourceType... types) {
+ Resources resources = new Resources();
+ for (ResourceType producedType : types) {
+ resources.add(producedType, 1);
+ }
+ return resources;
+ }
+}
bgstack15