diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-05-20 10:44:01 +0200 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-05-20 10:44:01 +0200 |
commit | 0296f9582b0c2b6154cd25398ae8ed016970471b (patch) | |
tree | 6db03771ea4caf11a6abb5a1b7be4694520385f1 | |
parent | WIP back to JVM for common module to see if it works (diff) | |
download | seven-wonders-0296f9582b0c2b6154cd25398ae8ed016970471b.tar.gz seven-wonders-0296f9582b0c2b6154cd25398ae8ed016970471b.tar.bz2 seven-wonders-0296f9582b0c2b6154cd25398ae8ed016970471b.zip |
Fix some tests
-rw-r--r-- | sw-common-model/build.gradle.kts | 3 | ||||
-rw-r--r-- | sw-common-model/src/test/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt (renamed from sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt) | 47 | ||||
-rw-r--r-- | sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt | 3 |
3 files changed, 24 insertions, 29 deletions
diff --git a/sw-common-model/build.gradle.kts b/sw-common-model/build.gradle.kts index 9c8eff58..81c58543 100644 --- a/sw-common-model/build.gradle.kts +++ b/sw-common-model/build.gradle.kts @@ -5,4 +5,7 @@ plugins { dependencies { implementation(kotlin("stdlib-jdk8")) + + testImplementation(kotlin("test")) + testImplementation(kotlin("test-junit")) } diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt b/sw-common-model/src/test/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt index 0b561938..9757ff86 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt +++ b/sw-common-model/src/test/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt @@ -1,26 +1,20 @@ -package org.luxons.sevenwonders.game.data.definitions +package org.luxons.sevenwonders.game.api -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.random.Random +import kotlin.test.BeforeTest +import kotlin.test.Test import kotlin.test.assertEquals -@RunWith(Theories::class) class WonderSidePickMethodTest { private lateinit var random: Random private lateinit var random2: Random - @Before + @BeforeTest fun setUp() { - random = Random(123) // starts with TRUE - random2 = Random(123456) // starts with FALSE + random = Random(421) // starts with TRUE + random2 = Random(42) // starts with FALSE } @Test @@ -46,6 +40,8 @@ class WonderSidePickMethodTest { var side = WonderSidePickMethod.EACH_RANDOM.pickSide(random, null) assertEquals(WonderSide.A, 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.A, side) @@ -53,8 +49,6 @@ class WonderSidePickMethodTest { 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 @@ -62,23 +56,26 @@ class WonderSidePickMethodTest { var side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, null) assertEquals(WonderSide.B, side) side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, side) - assertEquals(WonderSide.A, side) + assertEquals(WonderSide.B, side) side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, side) assertEquals(WonderSide.A, side) side = WonderSidePickMethod.EACH_RANDOM.pickSide(random2, side) - assertEquals(WonderSide.B, 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) } - @Theory - fun pick_allSameRandom_sameAsFirst(firstSide: WonderSide) { - var side = firstSide + @Test + fun pick_allSameRandom_sameAsFirst() { + repeat(10) { + val side = WonderSidePickMethod.SAME_RANDOM_FOR_ALL.pickSide(random, WonderSide.A) + assertEquals(WonderSide.A, side) + } repeat(10) { - side = WonderSidePickMethod.SAME_RANDOM_FOR_ALL.pickSide(random, side) - assertEquals(firstSide, side) + val side = WonderSidePickMethod.SAME_RANDOM_FOR_ALL.pickSide(random, WonderSide.B) + assertEquals(WonderSide.B, side) } } @@ -87,10 +84,4 @@ class WonderSidePickMethodTest { 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)) |