diff options
-rw-r--r-- | src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java | 43 | ||||
-rw-r--r-- | src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java | 80 |
2 files changed, 43 insertions, 80 deletions
diff --git a/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java b/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java new file mode 100644 index 00000000..ff044f4c --- /dev/null +++ b/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java @@ -0,0 +1,43 @@ +package org.luxons.sevenwonders.game.boards; + +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.Settings; +import org.luxons.sevenwonders.game.resources.ResourceType; +import org.luxons.sevenwonders.game.resources.Resources; +import org.luxons.sevenwonders.game.test.TestUtils; + +import static junit.framework.TestCase.assertEquals; +import static org.junit.Assert.assertTrue; + +@RunWith(Theories.class) +public class BoardTest { + + @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 initialGold_respectsSettings(int goldAmountInSettings) { + Settings settings = new Settings(); + settings.setInitialGold(goldAmountInSettings); + Board board = new Board(TestUtils.createWonder(), settings); + assertEquals(goldAmountInSettings, board.getGold()); + } + + @Theory + public void initialProduction_containsInitialResource(ResourceType type) { + Board board = new Board(TestUtils.createWonder(type), new Settings()); + Resources resources = TestUtils.createResources(type); + assertTrue(board.getProduction().contains(resources)); + } + +}
\ No newline at end of file diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java deleted file mode 100644 index 8dee5a77..00000000 --- a/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.luxons.sevenwonders.game.effects; - -import org.junit.Before; -import org.junit.Test; -import org.luxons.sevenwonders.game.Settings; -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.wonders.Wonder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class EffectTest { - - private static final int INITIAL_GOLD = 3; - - private Board board; - - private Board leftBoard; - - private Board rightBoard; - - private Resources resources1Stone1Wood; - - private Resources resources2Stones; - - private Resources resources2Stones3Clay; - - @Before - public void init() { - Settings settings = new Settings(); - settings.setInitialGold(INITIAL_GOLD); - - board = new Board(new Wonder("TestWonder", ResourceType.WOOD), settings); - leftBoard = new Board(new Wonder("TestWonder", ResourceType.STONE), settings); - rightBoard = new Board(new Wonder("TestWonder", ResourceType.PAPYRUS), settings); - - resources1Stone1Wood = new Resources(); - resources1Stone1Wood.add(ResourceType.STONE, 1); - resources1Stone1Wood.add(ResourceType.WOOD, 1); - - resources2Stones = new Resources(); - resources2Stones.add(ResourceType.STONE, 2); - - resources2Stones3Clay = new Resources(); - resources2Stones3Clay.add(ResourceType.STONE, 2); - resources2Stones3Clay.add(ResourceType.CLAY, 3); - } - - @Test - public void testInitialBoard() { - assertEquals(3, board.getGold()); - } - - @Test - public void testGoldIncrease() { - GoldIncrease effect = new GoldIncrease(6); - effect.apply(board, leftBoard, rightBoard); - assertEquals(INITIAL_GOLD + 6, board.getGold()); - assertEquals(INITIAL_GOLD, leftBoard.getGold()); - assertEquals(INITIAL_GOLD, rightBoard.getGold()); - } - - @Test - public void testProductionIncrease_standard() { - ProductionIncrease effect = new ProductionIncrease(); - effect.getProduction().addAll(resources2Stones3Clay); - effect.apply(board, leftBoard, rightBoard); - assertTrue(board.getProduction().contains(resources2Stones3Clay)); - } - - @Test - public void testProductionIncrease_choice() { - ProductionIncrease effect = new ProductionIncrease(); - effect.getProduction().addChoice(ResourceType.ORE, ResourceType.STONE); - effect.apply(board, leftBoard, rightBoard); - assertTrue(board.getProduction().contains(resources1Stone1Wood)); - } -}
\ No newline at end of file |