diff options
author | jbion <joffrey.bion@amadeus.com> | 2016-12-22 00:26:20 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2016-12-22 00:26:20 +0100 |
commit | 606709b1347170f303f55e15c98f845d7a2f1e3d (patch) | |
tree | 423a20da0f70add2077ad3db594ed68990e36eb2 /src/test/java | |
parent | Remove unused "nb of guild cards" setting (diff) | |
download | seven-wonders-606709b1347170f303f55e15c98f845d7a2f1e3d.tar.gz seven-wonders-606709b1347170f303f55e15c98f845d7a2f1e3d.tar.bz2 seven-wonders-606709b1347170f303f55e15c98f845d7a2f1e3d.zip |
Huge refac to pass the Table instead of left/right/self boards
Diffstat (limited to 'src/test/java')
6 files changed, 23 insertions, 24 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 index ff044f4c..0ac96203 100644 --- a/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java +++ b/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java @@ -17,7 +17,7 @@ public class BoardTest { @DataPoints public static int[] goldAmounts() { - return new int[]{-5, -1, 0, 1, 2, 5, 10}; + return new int[]{-5, -1, 0, 1, 2, 3, 5, 10}; } @DataPoints @@ -29,13 +29,13 @@ public class BoardTest { public void initialGold_respectsSettings(int goldAmountInSettings) { Settings settings = new Settings(); settings.setInitialGold(goldAmountInSettings); - Board board = new Board(TestUtils.createWonder(), settings); + Board board = new Board(TestUtils.createWonder(), null, settings); assertEquals(goldAmountInSettings, board.getGold()); } @Theory public void initialProduction_containsInitialResource(ResourceType type) { - Board board = new Board(TestUtils.createWonder(type), new Settings()); + Board board = new Board(TestUtils.createWonder(type), null, new Settings()); Resources resources = TestUtils.createResources(type); assertTrue(board.getProduction().contains(resources)); } diff --git a/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java b/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java index cbd2fd71..351aee35 100644 --- a/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java +++ b/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java @@ -1,11 +1,13 @@ package org.luxons.sevenwonders.game.cards; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.junit.Before; import org.junit.Test; import org.luxons.sevenwonders.game.Settings; +import org.luxons.sevenwonders.game.api.Table; import org.luxons.sevenwonders.game.boards.Board; import org.luxons.sevenwonders.game.effects.Effect; import org.luxons.sevenwonders.game.effects.ProductionIncrease; @@ -16,20 +18,19 @@ import static org.junit.Assert.assertEquals; public class CardTest { - private Board board; - - private Board leftBoard; - - private Board rightBoard; + private Table table; private Card treeFarmCard; @Before public void initBoard() { Settings settings = new Settings(); - 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); + + List<Board> boards = new ArrayList<>(3); + boards.add(new Board(new Wonder("TestWonder", ResourceType.WOOD), null, settings)); + boards.add(new Board(new Wonder("TestWonder", ResourceType.STONE), null, settings)); + boards.add(new Board(new Wonder("TestWonder", ResourceType.PAPYRUS), null, settings)); + table = new Table(boards); Requirements treeFarmRequirements = new Requirements(); treeFarmRequirements.setGold(1); @@ -43,15 +44,13 @@ public class CardTest { } @Test - public void testInitialBoard() { - assertEquals(3, board.getGold()); - } - - @Test public void playCardCostingMoney() { - board.setGold(3); - treeFarmCard.applyTo(board, leftBoard, rightBoard); - assertEquals(2, board.getGold()); + table.getBoard(0).setGold(3); + table.getBoard(1).setGold(3); + table.getBoard(2).setGold(3); + treeFarmCard.applyTo(table, 0); + assertEquals(2, table.getBoard(0).getGold()); + assertEquals(3, table.getBoard(1).getGold()); + assertEquals(3, table.getBoard(2).getGold()); } - } diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java index fdc4467e..f29eb286 100644 --- a/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java +++ b/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java @@ -28,7 +28,7 @@ public class GoldIncreaseTest { Board board = TestUtils.createBoard(type, initialAmount); GoldIncrease goldIncrease = new GoldIncrease(goldIncreaseAmount); - goldIncrease.apply(board, null, null); + goldIncrease.apply(board); assertEquals(initialAmount + goldIncreaseAmount, board.getGold()); } diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java index b5c9a2ee..0f95bea9 100644 --- a/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java +++ b/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java @@ -30,7 +30,7 @@ public class MilitaryReinforcementsTest { MilitaryReinforcements reinforcements = new MilitaryReinforcements(additionalShields); - reinforcements.apply(board, null, null); + reinforcements.apply(board); assertEquals(initialShields + additionalShields, board.getNbWarSymbols()); } diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java index d8ecf3ad..9ff35db3 100644 --- a/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java +++ b/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java @@ -31,7 +31,7 @@ public class ProductionIncreaseTest { Board board = TestUtils.createBoard(initialType); ProductionIncrease effect = createProductionIncrease(addedType); - effect.apply(board, null, null); + effect.apply(board); Resources resources = TestUtils.createResources(initialType, addedType); assertTrue(board.getProduction().contains(resources)); diff --git a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java index 1eebd3e4..2a0292cd 100644 --- a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java +++ b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java @@ -12,7 +12,7 @@ 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); + return new Board(wonder, null, settings); } public static Board createBoard(ResourceType initialResource, ResourceType... production) { |