summaryrefslogtreecommitdiff
path: root/sw-common-model/src/commonTest
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2019-05-22 02:17:33 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2019-05-22 02:17:33 +0200
commit36a3b94972fb30a1e9a17973d55179c7a4595b28 (patch)
tree0a7d6cd6cd8e89b081a88690029a42356a98a702 /sw-common-model/src/commonTest
parentFix tests (diff)
downloadseven-wonders-36a3b94972fb30a1e9a17973d55179c7a4595b28.tar.gz
seven-wonders-36a3b94972fb30a1e9a17973d55179c7a4595b28.tar.bz2
seven-wonders-36a3b94972fb30a1e9a17973d55179c7a4595b28.zip
Make common project multiplatform
Diffstat (limited to 'sw-common-model/src/commonTest')
-rw-r--r--sw-common-model/src/commonTest/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt87
1 files changed, 87 insertions, 0 deletions
diff --git a/sw-common-model/src/commonTest/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt b/sw-common-model/src/commonTest/kotlin/org/luxons/sevenwonders/game/api/WonderSidePickMethodTest.kt
new file mode 100644
index 00000000..9757ff86
--- /dev/null
+++ b/sw-common-model/src/commonTest/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