diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2018-07-06 00:43:50 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@amadeus.com> | 2018-07-06 16:06:23 +0200 |
commit | 9049dd004df71619e08a350c0a6e49455041d31b (patch) | |
tree | 3abc77d660f646bb64e9ab13549bdd16442de7cd /game-engine/src/test/java | |
parent | Kotlin mig: game definitions (diff) | |
download | seven-wonders-9049dd004df71619e08a350c0a6e49455041d31b.tar.gz seven-wonders-9049dd004df71619e08a350c0a6e49455041d31b.tar.bz2 seven-wonders-9049dd004df71619e08a350c0a6e49455041d31b.zip |
Kotlin mig: cards package
Diffstat (limited to 'game-engine/src/test/java')
8 files changed, 16 insertions, 556 deletions
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java index 9beb44fd..de187d26 100644 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java +++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java @@ -71,16 +71,6 @@ public class GameTest { checkLastPlayedMoves(sentMoves, table); } - private static void checkLastPlayedMoves(Map<Integer, PlayerMove> sentMoves, Table table) { - for (Move move : table.getLastPlayedMoves()) { - PlayerMove sentMove = sentMoves.get(move.getPlayerIndex()); - assertNotNull(sentMove); - assertNotNull(move.getCard()); - assertEquals(sentMove.getCardName(), move.getCard().getName()); - assertSame(sentMove.getType(), move.getType()); - } - } - private static PlayerMove getFirstAvailableMove(PlayerTurnInfo turnInfo) { switch (turnInfo.getAction()) { case PLAY: @@ -99,11 +89,11 @@ public class GameTest { for (HandCard handCard : turnInfo.getHand()) { if (handCard.isPlayable()) { Set<ResourceTransaction> resourcesToBuy = findResourcesToBuyFor(handCard, turnInfo); - return TestUtilsKt.createPlayerMove(MoveType.PLAY, handCard.getCard().getName(), resourcesToBuy); + return new PlayerMove(MoveType.PLAY, handCard.getCard().getName(), resourcesToBuy); } } HandCard firstCardInHand = turnInfo.getHand().get(0); - return TestUtilsKt.createPlayerMove(MoveType.DISCARD, firstCardInHand.getCard().getName()); + return new PlayerMove(MoveType.DISCARD, firstCardInHand.getCard().getName()); } private static Set<ResourceTransaction> findResourcesToBuyFor(HandCard handCard, PlayerTurnInfo turnInfo) { @@ -122,6 +112,16 @@ public class GameTest { assertNotNull(neighbourGuilds); assertFalse(neighbourGuilds.isEmpty()); String cardName = neighbourGuilds.get(0).getName(); - return TestUtilsKt.createPlayerMove(MoveType.COPY_GUILD, cardName); + return new PlayerMove(MoveType.COPY_GUILD, cardName); + } + + private static void checkLastPlayedMoves(Map<Integer, PlayerMove> sentMoves, Table table) { + for (Move move : table.getLastPlayedMoves()) { + PlayerMove sentMove = sentMoves.get(move.getPlayerIndex()); + assertNotNull(sentMove); + assertNotNull(move.getCard()); + assertEquals(sentMove.getCardName(), move.getCard().getName()); + assertSame(sentMove.getType(), move.getType()); + } } } diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardBackTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardBackTest.java deleted file mode 100644 index 6f637f87..00000000 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardBackTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.luxons.sevenwonders.game.cards; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class CardBackTest { - - @Test - public void initializedWithImage() { - String imagePath = "whateverimage.png"; - CardBack back = new CardBack(imagePath); - assertEquals(imagePath, back.getImage()); - } -} diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java deleted file mode 100644 index b9681434..00000000 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java +++ /dev/null @@ -1,110 +0,0 @@ -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; -import org.luxons.sevenwonders.game.resources.ResourceTransactions; -import org.luxons.sevenwonders.game.resources.ResourceType; -import org.luxons.sevenwonders.game.test.TestUtilsKt; -import org.luxons.sevenwonders.game.wonders.Wonder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; - -public class CardTest { - - private Table table; - - private Card treeFarmCard; - - @Before - public void initBoard() { - Settings settings = new Settings(3); - - List<Board> boards = new ArrayList<>(3); - boards.add(new Board(new Wonder("TestWonder", ResourceType.WOOD), 0, settings)); - boards.add(new Board(new Wonder("TestWonder", ResourceType.STONE), 1, settings)); - boards.add(new Board(new Wonder("TestWonder", ResourceType.PAPYRUS), 2, settings)); - table = new Table(boards); - - Requirements treeFarmRequirements = new Requirements(); - treeFarmRequirements.setGold(1); - - ProductionIncrease treeFarmEffect = new ProductionIncrease(); - treeFarmEffect.getProduction().addChoice(ResourceType.WOOD, ResourceType.CLAY); - - List<Effect> effects = Collections.singletonList(treeFarmEffect); - - treeFarmCard = new Card("Tree Farm", Color.BROWN, treeFarmRequirements, effects, "", null, null); - } - - @Test - public void playCardCostingMoney() { - table.getBoard(0).setGold(3); - table.getBoard(1).setGold(3); - table.getBoard(2).setGold(3); - treeFarmCard.applyTo(table, 0, new ResourceTransactions()); - assertEquals(2, table.getBoard(0).getGold()); - assertEquals(3, table.getBoard(1).getGold()); - assertEquals(3, table.getBoard(2).getGold()); - } - - @Test - public void equals_falseWhenNull() { - Card card = TestUtilsKt.testCard("TestCard"); - //noinspection ObjectEqualsNull - assertFalse(card.equals(null)); - } - - @Test - public void equals_falseWhenDifferentClass() { - Card card = TestUtilsKt.testCard("TestCard"); - Object object = new Object(); - //noinspection EqualsBetweenInconvertibleTypes - assertFalse(card.equals(object)); - } - - @Test - public void equals_trueWhenSame() { - Card card = TestUtilsKt.testCard("TestCard"); - assertEquals(card, card); - } - - @Test - public void equals_trueWhenSameContent() { - Card card1 = TestUtilsKt.testCard("TestCard"); - Card card2 = TestUtilsKt.testCard("TestCard"); - assertTrue(card1.equals(card2)); - } - - @Test - public void equals_falseWhenDifferentName() { - Card card1 = TestUtilsKt.testCard("TestCard1"); - Card card2 = TestUtilsKt.testCard("TestCard2"); - assertFalse(card1.equals(card2)); - } - - @Test - public void hashCode_sameWhenSameContent() { - Card card1 = TestUtilsKt.testCard("TestCard"); - Card card2 = TestUtilsKt.testCard("TestCard"); - assertEquals(card1.hashCode(), card2.hashCode()); - } - - @Test - public void hashCode_differentWhenDifferentName() { - Card card1 = TestUtilsKt.testCard("TestCard1"); - Card card2 = TestUtilsKt.testCard("TestCard2"); - assertNotEquals(card1.hashCode(), card2.hashCode()); - } -} diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/DecksTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/DecksTest.java deleted file mode 100644 index f572c5ac..00000000 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/DecksTest.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.luxons.sevenwonders.game.cards; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.luxons.sevenwonders.game.cards.Decks.CardNotFoundException; -import org.luxons.sevenwonders.game.test.TestUtilsKt; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; - -@RunWith(Theories.class) -public class DecksTest { - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @DataPoints - public static int[] dataPoints() { - return new int[] {1, 2, 3, 5, 10}; - } - - private static Decks createDecks(int nbAges, int nbCardsPerAge) { - Map<Integer, List<Card>> cardsPerAge = new HashMap<>(); - for (int age = 1; age <= nbAges; age++) { - int firstCardNumber = (age - 1) * nbCardsPerAge; - cardsPerAge.put(age, TestUtilsKt.createSampleCards(firstCardNumber, nbCardsPerAge)); - } - return new Decks(cardsPerAge); - } - - @Test(expected = CardNotFoundException.class) - public void getCard_failsOnNullNameWhenDeckIsEmpty() { - Decks decks = createDecks(0, 0); - decks.getCard(null); - } - - @Test(expected = CardNotFoundException.class) - public void getCard_failsOnEmptyNameWhenDeckIsEmpty() { - Decks decks = createDecks(0, 0); - decks.getCard(""); - } - - @Test(expected = CardNotFoundException.class) - public void getCard_failsWhenDeckIsEmpty() { - Decks decks = createDecks(0, 0); - decks.getCard("Any name"); - } - - @Test(expected = CardNotFoundException.class) - public void getCard_failsWhenCardIsNotFound() { - Decks decks = createDecks(3, 20); - decks.getCard("Unknown name"); - } - - @Test - public void getCard_succeedsWhenCardIsFound() { - Decks decks = createDecks(3, 20); - Card card = decks.getCard("Test Card 3"); - assertEquals("Test Card 3", card.getName()); - } - - @Test(expected = IllegalArgumentException.class) - public void deal_failsOnZeroPlayers() { - Decks decks = createDecks(3, 20); - decks.deal(1, 0); - } - - @Test(expected = IllegalArgumentException.class) - public void deal_failsOnMissingAge() { - Decks decks = createDecks(2, 0); - decks.deal(4, 10); - } - - @Theory - public void deal_failsWhenTooFewPlayers(int nbPlayers, int nbCards) { - assumeTrue(nbCards % nbPlayers != 0); - thrown.expect(IllegalArgumentException.class); - Decks decks = createDecks(1, nbCards); - decks.deal(1, nbPlayers); - } - - @Theory - public void deal_succeedsOnZeroCards(int nbPlayers) { - Decks decks = createDecks(1, 0); - Hands hands = decks.deal(1, nbPlayers); - for (int i = 0; i < nbPlayers; i++) { - assertNotNull(hands.get(i)); - assertTrue(hands.get(i).isEmpty()); - } - } - - @Theory - public void deal_evenDistribution(int nbPlayers, int nbCardsPerPlayer) { - int nbCardsPerAge = nbPlayers * nbCardsPerPlayer; - Decks decks = createDecks(1, nbCardsPerAge); - Hands hands = decks.deal(1, nbPlayers); - for (int i = 0; i < nbPlayers; i++) { - assertEquals(nbCardsPerPlayer, hands.get(i).size()); - } - } -} diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandRotationDirectionTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandRotationDirectionTest.java deleted file mode 100644 index ddd69b70..00000000 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandRotationDirectionTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.luxons.sevenwonders.game.cards; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class HandRotationDirectionTest { - - @Test - public void testAgesDirections() { - assertEquals(HandRotationDirection.LEFT, HandRotationDirection.forAge(1)); - assertEquals(HandRotationDirection.RIGHT, HandRotationDirection.forAge(2)); - assertEquals(HandRotationDirection.LEFT, HandRotationDirection.forAge(3)); - } -} diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java deleted file mode 100644 index 463dafcc..00000000 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.luxons.sevenwonders.game.cards; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Test; -import org.junit.experimental.theories.DataPoints; -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.TestUtilsKt; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; - -@RunWith(Theories.class) -public class HandsTest { - - @DataPoints("nbCardsPerPlayer") - public static int[] nbCardsPerPlayer() { - return new int[] {0, 1, 2, 3, 4, 5, 6, 7}; - } - - @DataPoints("nbPlayers") - public static int[] nbPlayers() { - return new int[] {3, 4, 5, 6, 7}; - } - - private static Hands createHands(int nbPlayers, int nbCardsPerPlayer) { - Map<Integer, List<Card>> hands = new HashMap<>(); - for (int p = 0; p < nbPlayers; p++) { - int firstCardNumber = (p - 1) * nbCardsPerPlayer; - hands.put(p, TestUtilsKt.createSampleCards(firstCardNumber, nbCardsPerPlayer)); - } - return new Hands(hands, nbPlayers); - } - - @Test(expected = PlayerIndexOutOfBoundsException.class) - public void get_failsOnMissingPlayer() { - Hands hands = createHands(4, 7); - hands.get(5); - } - - @Test - public void get_retrievesCorrectCards() { - List<Card> hand0 = TestUtilsKt.createSampleCards(0, 5); - List<Card> hand1 = TestUtilsKt.createSampleCards(5, 10); - Map<Integer, List<Card>> handsMap = new HashMap<>(); - handsMap.put(0, hand0); - handsMap.put(1, hand1); - Hands hands = new Hands(handsMap, 2); - assertEquals(hand0, hands.get(0)); - assertEquals(hand1, hands.get(1)); - } - - @Theory - public void isEmpty_falseWhenAtLeast1_allSame(@FromDataPoints("nbPlayers") int nbPlayers, - @FromDataPoints("nbCardsPerPlayer") int nbCardsPerPlayer) { - assumeTrue(nbCardsPerPlayer >= 1); - Hands hands = createHands(nbPlayers, nbCardsPerPlayer); - assertFalse(hands.isEmpty()); - } - - @Theory - public void isEmpty_trueWhenAllEmpty(@FromDataPoints("nbPlayers") int nbPlayers) { - Hands hands = createHands(nbPlayers, 0); - assertTrue(hands.isEmpty()); - } - - @Theory - public void maxOneCardRemains_falseWhenAtLeast2_allSame(@FromDataPoints("nbPlayers") int nbPlayers, - @FromDataPoints("nbCardsPerPlayer") int nbCardsPerPlayer) { - assumeTrue(nbCardsPerPlayer >= 2); - Hands hands = createHands(nbPlayers, nbCardsPerPlayer); - assertFalse(hands.maxOneCardRemains()); - } - - @Theory - public void maxOneCardRemains_trueWhenAtMost1_allSame(@FromDataPoints("nbPlayers") int nbPlayers, - @FromDataPoints("nbCardsPerPlayer") int nbCardsPerPlayer) { - assumeTrue(nbCardsPerPlayer <= 1); - Hands hands = createHands(nbPlayers, nbCardsPerPlayer); - assertTrue(hands.maxOneCardRemains()); - } - - @Theory - public void maxOneCardRemains_trueWhenAtMost1_someZero(@FromDataPoints("nbPlayers") int nbPlayers) { - Hands hands = createHands(nbPlayers, 1); - hands.get(0).remove(0); - assertTrue(hands.maxOneCardRemains()); - } - - @Theory - public void gatherAndClear(@FromDataPoints("nbPlayers") int nbPlayers, - @FromDataPoints("nbCardsPerPlayer") int nbCardsPerPlayer) { - Hands hands = createHands(nbPlayers, nbCardsPerPlayer); - List<Card> remainingCards = hands.gatherAndClear(); - assertEquals(nbPlayers * nbCardsPerPlayer, remainingCards.size()); - assertTrue(hands.isEmpty()); - } - - @Test - public void rotate_movesOfCorrectOffset_right() { - Hands hands = createHands(3, 7); - Hands rotated = hands.rotate(HandRotationDirection.RIGHT); - assertEquals(rotated.get(1), hands.get(0)); - assertEquals(rotated.get(2), hands.get(1)); - assertEquals(rotated.get(0), hands.get(2)); - } - - @Test - public void rotate_movesOfCorrectOffset_left() { - Hands hands = createHands(3, 7); - Hands rotated = hands.rotate(HandRotationDirection.LEFT); - assertEquals(rotated.get(2), hands.get(0)); - assertEquals(rotated.get(0), hands.get(1)); - assertEquals(rotated.get(1), hands.get(2)); - } - - @Test - public void createHand_containsAllCards() { - List<Card> hand0 = TestUtilsKt.createSampleCards(0, 5); - List<Card> hand1 = TestUtilsKt.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 = TestUtilsKt.testTable(2); - List<HandCard> hand = hands.createHand(table, 0); - - for (HandCard handCard : hand) { - assertTrue(hand0.contains(handCard.getCard())); - } - } -} diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java deleted file mode 100644 index 6707dfab..00000000 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.luxons.sevenwonders.game.cards; - -import java.util.Arrays; -import java.util.Collections; - -import org.junit.Test; -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.api.Table; -import org.luxons.sevenwonders.game.boards.Board; -import org.luxons.sevenwonders.game.resources.Provider; -import org.luxons.sevenwonders.game.resources.ResourceTransactions; -import org.luxons.sevenwonders.game.resources.ResourceType; -import org.luxons.sevenwonders.game.resources.Resources; -import org.luxons.sevenwonders.game.test.TestUtilsKt; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; - -@RunWith(Theories.class) -public class RequirementsTest { - - @DataPoints - public static int[] goldAmounts() { - return new int[] {0, 1, 2, 5}; - } - - @DataPoints - public static ResourceType[] resourceTypes() { - return ResourceType.values(); - } - - @Test - public void getResources_emptyAfterInit() { - Requirements requirements = new Requirements(); - assertTrue(requirements.getResources().isEmpty()); - } - - @Test - public void setResources_success() { - Requirements requirements = new Requirements(); - Resources resources = new Resources(); - requirements.setResources(resources); - assertSame(resources, requirements.getResources()); - } - - @Theory - public void goldRequirement(int boardGold, int requiredGold) { - Requirements requirements = new Requirements(); - requirements.setGold(requiredGold); - - Board board = TestUtilsKt.testBoard(ResourceType.CLAY, boardGold); - Table table = new Table(Collections.singletonList(board)); - - assertEquals(boardGold >= requiredGold, requirements.areMetWithoutNeighboursBy(board)); - assertEquals(boardGold >= requiredGold, requirements.areMetWithHelpBy(board, new ResourceTransactions())); - assertEquals(boardGold >= requiredGold, requirements.areMetBy(table, 0)); - } - - @Theory - public void resourceRequirement_initialResource(ResourceType initialResource, ResourceType requiredResource) { - Requirements requirements = TestUtilsKt.createRequirements(requiredResource); - - Board board = TestUtilsKt.testBoard(initialResource, 0); - Table table = new Table(Collections.singletonList(board)); - - assertEquals(initialResource == requiredResource, requirements.areMetWithoutNeighboursBy(board)); - assertEquals(initialResource == requiredResource, - requirements.areMetWithHelpBy(board, new ResourceTransactions())); - - if (initialResource == requiredResource) { - assertTrue(requirements.areMetBy(table, 0)); - } - } - - @Theory - public void resourceRequirement_ownProduction(ResourceType initialResource, ResourceType producedResource, - ResourceType requiredResource) { - assumeTrue(initialResource != requiredResource); - - Requirements requirements = TestUtilsKt.createRequirements(requiredResource); - - Board board = TestUtilsKt.testBoard(initialResource, 0); - board.getProduction().addFixedResource(producedResource, 1); - Table table = new Table(Collections.singletonList(board)); - - assertEquals(producedResource == requiredResource, requirements.areMetWithoutNeighboursBy(board)); - assertEquals(producedResource == requiredResource, - requirements.areMetWithHelpBy(board, new ResourceTransactions())); - - if (producedResource == requiredResource) { - assertTrue(requirements.areMetBy(table, 0)); - } - } - - @Theory - public void resourceRequirement_boughtResource(ResourceType initialResource, ResourceType boughtResource, - ResourceType requiredResource) { - assumeTrue(initialResource != requiredResource); - - Requirements requirements = TestUtilsKt.createRequirements(requiredResource); - - Board board = TestUtilsKt.testBoard(initialResource, 2); - Board neighbourBoard = TestUtilsKt.testBoard(initialResource, 0); - neighbourBoard.getPublicProduction().addFixedResource(boughtResource, 1); - Table table = new Table(Arrays.asList(board, neighbourBoard)); - - ResourceTransactions resources = TestUtilsKt.createTransactions(Provider.RIGHT_PLAYER, boughtResource); - - assertFalse(requirements.areMetWithoutNeighboursBy(board)); - assertEquals(boughtResource == requiredResource, requirements.areMetWithHelpBy(board, resources)); - - if (boughtResource == requiredResource) { - assertTrue(requirements.areMetBy(table, 0)); - } - } - - @Theory - public void pay_boughtResource(ResourceType initialResource, ResourceType requiredResource) { - assumeTrue(initialResource != requiredResource); - - Requirements requirements = TestUtilsKt.createRequirements(requiredResource); - - Board board = TestUtilsKt.testBoard(initialResource, 2); - Board neighbourBoard = TestUtilsKt.testBoard(requiredResource, 0); - Table table = new Table(Arrays.asList(board, neighbourBoard)); - - ResourceTransactions transactions = TestUtilsKt.createTransactions(Provider.RIGHT_PLAYER, - requiredResource); - - assertFalse(requirements.areMetWithoutNeighboursBy(board)); - assertTrue(requirements.areMetWithHelpBy(board, transactions)); - assertTrue(requirements.areMetBy(table, 0)); - - requirements.pay(table, 0, transactions); - - assertEquals(0, board.getGold()); - assertEquals(2, neighbourBoard.getGold()); - } -} diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.java index c58e1671..87e1d704 100644 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.java +++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.java @@ -17,7 +17,7 @@ public class BuildWonderMoveTest { @Test(expected = InvalidMoveException.class) public void validate_failsWhenCardNotInHand() { Table table = TestUtilsKt.testTable(3); - List<Card> hand = TestUtilsKt.createSampleCards(0, 7); + List<Card> hand = TestUtilsKt.sampleCards(0, 7); Card anotherCard = TestUtilsKt.testCard("Card that is not in the hand"); Move move = TestUtilsKt.createMove(0, anotherCard, MoveType.UPGRADE_WONDER); @@ -28,7 +28,7 @@ public class BuildWonderMoveTest { public void validate_failsWhenWonderIsCompletelyBuilt() { Settings settings = TestUtilsKt.testSettings(3); Table table = TestUtilsKt.testTable(settings); - List<Card> hand = TestUtilsKt.createSampleCards(0, 7); + List<Card> hand = TestUtilsKt.sampleCards(0, 7); fillPlayerWonderLevels(settings, table, hand); @@ -59,7 +59,7 @@ public class BuildWonderMoveTest { public void place_increasesWonderLevel() { Settings settings = TestUtilsKt.testSettings(3); Table table = TestUtilsKt.testTable(settings); - List<Card> hand = TestUtilsKt.createSampleCards(0, 7); + List<Card> hand = TestUtilsKt.sampleCards(0, 7); Card cardToUse = hand.get(0); Move move = TestUtilsKt.createMove(0, cardToUse, MoveType.UPGRADE_WONDER); move.validate(table, hand); // should not fail |