diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2019-05-22 02:17:33 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2019-05-22 02:17:33 +0200 |
commit | 36a3b94972fb30a1e9a17973d55179c7a4595b28 (patch) | |
tree | 0a7d6cd6cd8e89b081a88690029a42356a98a702 /sw-common-model/src/commonTest | |
parent | Fix tests (diff) | |
download | seven-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.kt | 87 |
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)) + } +} |