summaryrefslogtreecommitdiff
path: root/game-engine/src/test/kotlin
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2018-08-01 02:24:40 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2018-08-01 02:24:40 +0200
commit880a4fff4232317dd00ab0ee9992a33d459b9862 (patch)
tree9b554fc8870e988e8bdf772642ece558e6df780e /game-engine/src/test/kotlin
parentRemove checkstyle and add ktlint (diff)
downloadseven-wonders-880a4fff4232317dd00ab0ee9992a33d459b9862.tar.gz
seven-wonders-880a4fff4232317dd00ab0ee9992a33d459b9862.tar.bz2
seven-wonders-880a4fff4232317dd00ab0ee9992a33d459b9862.zip
Fix comparisons of ResourceTransactions
This commit abstracts away the actual type of collection in the ResourceTransactions typealias. Incidentally, it also changes it to Set, so that tests can compare without concerns about order. This also means that duplicates are not tolerated anymore, and I still haven't decided whether this is good or bad.
Diffstat (limited to 'game-engine/src/test/kotlin')
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt6
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/TradingRulesTest.kt8
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt13
3 files changed, 11 insertions, 16 deletions
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt
index fb797b77..e1d8b7f9 100644
--- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt
@@ -13,10 +13,10 @@ import org.luxons.sevenwonders.game.api.Table
import org.luxons.sevenwonders.game.data.GameDefinitionLoader
import org.luxons.sevenwonders.game.data.LAST_AGE
import org.luxons.sevenwonders.game.moves.MoveType
-import org.luxons.sevenwonders.game.resources.ResourceTransaction
import org.luxons.sevenwonders.game.resources.ResourceTransactions
import org.luxons.sevenwonders.game.resources.Resources
import org.luxons.sevenwonders.game.resources.bestSolution
+import org.luxons.sevenwonders.game.resources.noTransactions
import org.luxons.sevenwonders.game.test.testCustomizableSettings
import java.util.HashMap
@@ -83,9 +83,9 @@ class GameTest {
return PlayerMove(MoveType.DISCARD, firstCardInHand.card.name)
}
- private fun findResourcesToBuyFor(handCard: HandCard, turnInfo: PlayerTurnInfo): Collection<ResourceTransaction> {
+ private fun findResourcesToBuyFor(handCard: HandCard, turnInfo: PlayerTurnInfo): ResourceTransactions {
if (handCard.isFree) {
- return emptyList()
+ return noTransactions()
}
val requiredResources = handCard.card.requirements.resources
val table = turnInfo.table
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/TradingRulesTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/TradingRulesTest.kt
index e44c38f3..3e567493 100644
--- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/TradingRulesTest.kt
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/TradingRulesTest.kt
@@ -8,7 +8,6 @@ import org.junit.experimental.theories.Theory
import org.junit.runner.RunWith
import org.luxons.sevenwonders.game.test.createTransaction
import org.luxons.sevenwonders.game.test.createTransactions
-import java.util.ArrayList
@RunWith(Theories::class)
class TradingRulesTest {
@@ -102,9 +101,10 @@ class TradingRulesTest {
val rules = TradingRules(defaultCost)
rules.setCost(type, overriddenProvider, overriddenCost)
- val boughtResources = ArrayList<ResourceTransaction>(2)
- boughtResources.add(createTransaction(provider, type))
- boughtResources.add(createTransaction(overriddenProvider, type))
+ val boughtResources = createTransactions(
+ createTransaction(provider, type),
+ createTransaction(overriddenProvider, type)
+ )
assertEquals(defaultCost + overriddenCost, rules.computeCost(boughtResources))
}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
index 383c77fa..c67a7052 100644
--- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
@@ -102,11 +102,11 @@ infix fun Int.of(type: ResourceType): Resources {
internal fun createTransactions(provider: Provider, vararg resources: ResourceType): ResourceTransactions {
val transaction = createTransaction(provider, *resources)
- return listOf(transaction)
+ return createTransactions(transaction)
}
internal fun createTransactions(vararg transactions: ResourceTransaction): ResourceTransactions {
- return transactions.toList()
+ return transactions.toSet()
}
fun createTransaction(provider: Provider, vararg resources: ResourceType): ResourceTransaction {
@@ -209,13 +209,8 @@ internal fun playCardWithEffect(player: Player, color: Color, effect: Effect) {
card.applyTo(player, noTransactions())
}
-internal fun createMove(
- context: PlayerContext,
- card: Card,
- type: MoveType,
- vararg transactions: ResourceTransaction
-): Move {
- val playerMove = PlayerMove(type, card.name, Arrays.asList(*transactions))
+internal fun createMove(context: PlayerContext, card: Card, type: MoveType): Move {
+ val playerMove = PlayerMove(type, card.name)
return type.create(playerMove, card, context)
}
bgstack15