summaryrefslogtreecommitdiff
path: root/game-engine/src/test/kotlin/org
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2018-07-08 13:30:41 +0200
committerjbion <joffrey.bion@amadeus.com>2018-07-08 13:34:13 +0200
commit3b844531a2f9ad8037c9666cfff00916b5321cf9 (patch)
treea8505a260ab6cccf4fb3c153c3a1009b0d5a559e /game-engine/src/test/kotlin/org
parentKotlin mig: api package tests (diff)
downloadseven-wonders-3b844531a2f9ad8037c9666cfff00916b5321cf9.tar.gz
seven-wonders-3b844531a2f9ad8037c9666cfff00916b5321cf9.tar.bz2
seven-wonders-3b844531a2f9ad8037c9666cfff00916b5321cf9.zip
Kotlin mig: wonders package
Diffstat (limited to 'game-engine/src/test/kotlin/org')
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt7
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt2
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/wonders/WonderTest.kt37
3 files changed, 41 insertions, 5 deletions
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt
index 3253136c..783e4c38 100644
--- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt
@@ -10,7 +10,6 @@ import org.luxons.sevenwonders.game.effects.ProductionIncrease
import org.luxons.sevenwonders.game.resources.Production
import org.luxons.sevenwonders.game.resources.ResourceTransactions
import org.luxons.sevenwonders.game.resources.ResourceType
-import org.luxons.sevenwonders.game.resources.Resources
import org.luxons.sevenwonders.game.test.testCard
import org.luxons.sevenwonders.game.wonders.Wonder
@@ -25,9 +24,9 @@ class CardTest {
val settings = Settings(3)
val boards = listOf(
- Board(Wonder("TestWonder", ResourceType.WOOD), 0, settings),
- Board(Wonder("TestWonder", ResourceType.STONE), 1, settings),
- Board(Wonder("TestWonder", ResourceType.PAPYRUS), 2, settings)
+ Board(Wonder("TestWonder", ResourceType.WOOD, emptyList(), ""), 0, settings),
+ Board(Wonder("TestWonder", ResourceType.STONE, emptyList(), ""), 1, settings),
+ Board(Wonder("TestWonder", ResourceType.PAPYRUS, emptyList(), ""), 2, settings)
)
table = Table(boards)
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
index 28ab714d..feda9423 100644
--- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
@@ -78,7 +78,7 @@ fun testWonder(initialResource: ResourceType = ResourceType.WOOD): Wonder {
val stage1 = createWonderStage()
val stage2 = createWonderStage()
val stage3 = createWonderStage()
- return Wonder("Test Wonder " + initialResource.symbol!!, initialResource, stage1, stage2, stage3)
+ return Wonder("Test Wonder " + initialResource.symbol!!, initialResource, listOf(stage1, stage2, stage3), "")
}
private fun createWonderStage(vararg effects: Effect): WonderStage {
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/wonders/WonderTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/wonders/WonderTest.kt
new file mode 100644
index 00000000..9270bcca
--- /dev/null
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/wonders/WonderTest.kt
@@ -0,0 +1,37 @@
+package org.luxons.sevenwonders.game.wonders
+
+import org.junit.Test
+import org.luxons.sevenwonders.game.cards.CardBack
+import org.luxons.sevenwonders.game.test.*
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.fail
+
+class WonderTest {
+
+ @Test
+ fun buildLevel_increasesNbBuiltStages() {
+ val wonder = testWonder()
+ assertEquals(0, wonder.nbBuiltStages.toLong())
+ wonder.buildLevel(CardBack("img"))
+ assertEquals(1, wonder.nbBuiltStages.toLong())
+ wonder.buildLevel(CardBack("img"))
+ assertEquals(2, wonder.nbBuiltStages.toLong())
+ wonder.buildLevel(CardBack("img"))
+ assertEquals(3, wonder.nbBuiltStages.toLong())
+ }
+
+ @Test
+ fun buildLevel_failsIfFull() {
+ val wonder = testWonder()
+ wonder.buildLevel(CardBack("img"))
+ wonder.buildLevel(CardBack("img"))
+ wonder.buildLevel(CardBack("img"))
+ try {
+ wonder.buildLevel(CardBack("img"))
+ fail()
+ } catch (e: IllegalStateException) {
+ // expected exception because there is no 4th level in this wonder
+ }
+ }
+}
bgstack15