summaryrefslogtreecommitdiff
path: root/sw-engine
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2019-05-20 10:44:01 +0200
committerjbion <joffrey.bion@amadeus.com>2019-05-20 10:44:01 +0200
commit0296f9582b0c2b6154cd25398ae8ed016970471b (patch)
tree6db03771ea4caf11a6abb5a1b7be4694520385f1 /sw-engine
parentWIP back to JVM for common module to see if it works (diff)
downloadseven-wonders-0296f9582b0c2b6154cd25398ae8ed016970471b.tar.gz
seven-wonders-0296f9582b0c2b6154cd25398ae8ed016970471b.tar.bz2
seven-wonders-0296f9582b0c2b6154cd25398ae8ed016970471b.zip
Fix some tests
Diffstat (limited to 'sw-engine')
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt96
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt3
2 files changed, 2 insertions, 97 deletions
diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt
deleted file mode 100644
index 0b561938..00000000
--- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.luxons.sevenwonders.game.data.definitions
-
-import org.junit.Before
-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.WonderSidePickMethod
-import java.util.Random
-import kotlin.test.assertEquals
-
-@RunWith(Theories::class)
-class WonderSidePickMethodTest {
-
- private lateinit var random: Random
-
- private lateinit var random2: Random
-
- @Before
- fun setUp() {
- random = Random(123) // starts with TRUE
- random2 = Random(123456) // starts with FALSE
- }
-
- @Test
- fun pick_allA() {
- var side: WonderSide? = null
- repeat(10) {
- side = WonderSidePickMethod.ALL_A.pickSide(random, side)
- assertEquals(WonderSide.A, side)
- }
- }
-
- @Test
- fun pick_allB() {
- var side: WonderSide? = null
- repeat(10) {
- side = WonderSidePickMethod.ALL_B.pickSide(random, side)
- assertEquals(WonderSide.B, side)
- }
- }
-
- @Test
- fun pick_eachRandom() {
- var side = WonderSidePickMethod.EACH_RANDOM.pickSide(random, null)
- assertEquals(WonderSide.A, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random, side)
- assertEquals(WonderSide.B, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random, side)
- assertEquals(WonderSide.A, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random, side)
- assertEquals(WonderSide.B, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random, side)
- assertEquals(WonderSide.B, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random, side)
- assertEquals(WonderSide.A, side)
- }
-
- @Test
- fun pick_eachRandom2() {
- var side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, null)
- assertEquals(WonderSide.B, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, side)
- assertEquals(WonderSide.A, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, side)
- assertEquals(WonderSide.A, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, side)
- assertEquals(WonderSide.B, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, side)
- assertEquals(WonderSide.B, side)
- side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, side)
- assertEquals(WonderSide.B, side)
- }
-
- @Theory
- fun pick_allSameRandom_sameAsFirst(firstSide: WonderSide) {
- var side = firstSide
- repeat(10) {
- side = WonderSidePickMethod.SAME_RANDOM_FOR_ALL.pickSide(random, side)
- assertEquals(firstSide, side)
- }
- }
-
- @Test
- fun pick_allSameRandom_firstIsRandom() {
- assertEquals(WonderSide.A, WonderSidePickMethod.SAME_RANDOM_FOR_ALL.pickSide(random, null))
- assertEquals(WonderSide.B, WonderSidePickMethod.SAME_RANDOM_FOR_ALL.pickSide(random2, null))
- }
-
- companion object {
-
- @DataPoints
- fun sides(): Array<WonderSide> = WonderSide.values()
- }
-}
diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
index ba6c1727..0e6eb2b7 100644
--- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
+++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
@@ -3,6 +3,7 @@ package org.luxons.sevenwonders.game.test
import org.luxons.sevenwonders.game.Player
import org.luxons.sevenwonders.game.PlayerContext
import org.luxons.sevenwonders.game.Settings
+import org.luxons.sevenwonders.game.api.ApiCountedResource
import org.luxons.sevenwonders.game.api.CustomizableSettings
import org.luxons.sevenwonders.game.api.PlayerMove
import org.luxons.sevenwonders.game.boards.Board
@@ -74,7 +75,7 @@ internal fun createTransactions(provider: Provider, vararg resources: ResourceTy
internal fun createTransactions(vararg transactions: ResourceTransaction): ResourceTransactions = transactions.toSet()
internal fun createTransaction(provider: Provider, vararg resources: ResourceType): ResourceTransaction =
- ResourceTransaction(provider, resourcesOf(*resources))
+ ResourceTransaction(provider, resources.map { ApiCountedResource(1, it) })
internal fun createRequirements(vararg types: ResourceType): Requirements = Requirements(resources = resourcesOf(*types))
bgstack15