summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2016-12-22 18:45:15 +0100
committerjbion <joffrey.bion@amadeus.com>2016-12-22 18:45:15 +0100
commitd29a6a41aace1eaf6e2f9932e748dbcae007471d (patch)
tree70e3d3bd5539731c77625511073229021ab7feab
parentHandle discarded cards at end of age (diff)
downloadseven-wonders-d29a6a41aace1eaf6e2f9932e748dbcae007471d.tar.gz
seven-wonders-d29a6a41aace1eaf6e2f9932e748dbcae007471d.tar.bz2
seven-wonders-d29a6a41aace1eaf6e2f9932e748dbcae007471d.zip
Add Hands.createHand() test
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java19
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java16
2 files changed, 34 insertions, 1 deletions
diff --git a/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java b/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java
index 86763450..4475fd3b 100644
--- a/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java
+++ b/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java
@@ -10,6 +10,8 @@ import org.junit.experimental.theories.FromDataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
+import org.luxons.sevenwonders.game.api.HandCard;
+import org.luxons.sevenwonders.game.api.Table;
import org.luxons.sevenwonders.game.cards.Hands.PlayerIndexOutOfBoundsException;
import org.luxons.sevenwonders.game.test.TestUtils;
@@ -137,4 +139,21 @@ public class HandsTest {
assertEquals(rotated.get(2), hands.get(1));
assertEquals(rotated.get(0), hands.get(2));
}
+
+ @Test
+ public void createHand_containsAllCards() {
+ List<Card> hand0 = TestUtils.createSampleCards(0, 5);
+ List<Card> hand1 = TestUtils.createSampleCards(5, 10);
+ Map<Integer, List<Card>> handsMap = new HashMap<>();
+ handsMap.put(0, hand0);
+ handsMap.put(1, hand1);
+ Hands hands = new Hands(handsMap, 2);
+
+ Table table = TestUtils.createTable(2);
+ List<HandCard> hand = hands.createHand(table, 0);
+
+ for (HandCard handCard : hand) {
+ assertTrue(hand0.contains(handCard.getCard()));
+ }
+ }
} \ 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
index 2a3bc379..968e4821 100644
--- a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
+++ b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
@@ -4,9 +4,11 @@ import java.util.ArrayList;
import java.util.List;
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.cards.Card;
import org.luxons.sevenwonders.game.cards.Color;
+import org.luxons.sevenwonders.game.cards.Requirements;
import org.luxons.sevenwonders.game.resources.Production;
import org.luxons.sevenwonders.game.resources.ResourceType;
import org.luxons.sevenwonders.game.resources.Resources;
@@ -14,6 +16,18 @@ import org.luxons.sevenwonders.game.wonders.Wonder;
public class TestUtils {
+ public static Table createTable(int nbPlayers) {
+ return new Table(createBoards(nbPlayers));
+ }
+
+ public static List<Board> createBoards(int count) {
+ List<Board> boards = new ArrayList<>(count);
+ for (int i = 0; i < count; i++) {
+ boards.add(createBoard(ResourceType.WOOD));
+ }
+ return boards;
+ }
+
public static Board createBoard(ResourceType initialResource) {
Settings settings = new Settings();
Wonder wonder = new Wonder("Test Wonder " + initialResource.getSymbol(), initialResource);
@@ -58,7 +72,7 @@ public class TestUtils {
public static List<Card> createSampleCards(int fromIndex, int nbCards) {
List<Card> sampleCards = new ArrayList<>();
for (int i = fromIndex; i < fromIndex + nbCards; i++) {
- sampleCards.add(new Card("Test Card " + i, Color.BLUE, null, null, null, null, null));
+ sampleCards.add(new Card("Test Card " + i, Color.BLUE, new Requirements(), null, null, null, null));
}
return sampleCards;
}
bgstack15