From 0296f9582b0c2b6154cd25398ae8ed016970471b Mon Sep 17 00:00:00 2001 From: jbion Date: Mon, 20 May 2019 10:44:01 +0200 Subject: Fix some tests --- .../data/definitions/WonderSidePickMethodTest.kt | 96 ---------------------- .../org/luxons/sevenwonders/game/test/TestUtils.kt | 3 +- 2 files changed, 2 insertions(+), 97 deletions(-) delete mode 100644 sw-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt (limited to 'sw-engine') 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.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)) -- cgit