summaryrefslogtreecommitdiff
path: root/sw-common-model
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-common-model
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-common-model')
-rw-r--r--sw-common-model/build.gradle.kts3
-rw-r--r--sw-common-model/src/test/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt87
2 files changed, 90 insertions, 0 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-common-model/src/test/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt b/sw-common-model/src/test/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt
new file mode 100644
index 00000000..9757ff86
--- /dev/null
+++ b/sw-common-model/src/test/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt
@@ -0,0 +1,87 @@
+package org.luxons.sevenwonders.game.api
+
+import kotlin.random.Random
+import kotlin.test.BeforeTest
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class WonderSidePickMethodTest {
+
+ private lateinit var random: Random
+
+ private lateinit var random2: Random
+
+ @BeforeTest
+ fun setUp() {
+ random = Random(421) // starts with TRUE
+ random2 = Random(42) // 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.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)
+ }
+
+ @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.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)
+ }
+
+ @Test
+ fun pick_allSameRandom_sameAsFirst() {
+ repeat(10) {
+ val side = WonderSidePickMethod.SAME_RANDOM_FOR_ALL.pickSide(random, WonderSide.A)
+ assertEquals(WonderSide.A, side)
+ }
+ repeat(10) {
+ val side = WonderSidePickMethod.SAME_RANDOM_FOR_ALL.pickSide(random, WonderSide.B)
+ assertEquals(WonderSide.B, 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))
+ }
+}
bgstack15