diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-02-19 22:15:42 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-02-19 22:24:21 +0100 |
commit | 02691e0981e762fdb1f2a1d8aceec10bd8dc7c99 (patch) | |
tree | 0fbd466472748047216eb49b15f223ba417e26ac /game-engine | |
parent | Migrate backend and game-engine builds to kotlin DSL (diff) | |
download | seven-wonders-02691e0981e762fdb1f2a1d8aceec10bd8dc7c99.tar.gz seven-wonders-02691e0981e762fdb1f2a1d8aceec10bd8dc7c99.tar.bz2 seven-wonders-02691e0981e762fdb1f2a1d8aceec10bd8dc7c99.zip |
Migrate JUnits to kotlin-test
Diffstat (limited to 'game-engine')
36 files changed, 175 insertions, 184 deletions
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt index 05de1eb4..1917c860 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt @@ -1,9 +1,5 @@ package org.luxons.sevenwonders.game -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertTrue import org.junit.Test import org.luxons.sevenwonders.game.api.Action import org.luxons.sevenwonders.game.api.HandCard @@ -19,6 +15,10 @@ import org.luxons.sevenwonders.game.resources.bestSolution import org.luxons.sevenwonders.game.resources.noTransactions import org.luxons.sevenwonders.game.test.testCustomizableSettings import java.util.HashMap +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotNull +import kotlin.test.assertTrue class GameTest { @@ -109,7 +109,7 @@ class GameTest { val sentMove = sentMoves[move.playerContext.index] assertNotNull(sentMove) assertNotNull(move.card) - assertEquals(sentMove!!.cardName, move.card.name) + assertEquals(sentMove.cardName, move.card.name) } } } diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/TableTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/TableTest.kt index dd212c0c..19e4e8e8 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/TableTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/TableTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.api -import org.junit.Assert.assertEquals import org.junit.Assume.assumeTrue import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.Theories @@ -9,6 +8,7 @@ import org.junit.runner.RunWith import org.luxons.sevenwonders.game.boards.RelativeBoardPosition import org.luxons.sevenwonders.game.test.createGuildCards import org.luxons.sevenwonders.game.test.testTable +import kotlin.test.assertEquals @RunWith(Theories::class) class TableTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/BoardTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/BoardTest.kt index e227bf63..d8a10777 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/BoardTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/BoardTest.kt @@ -1,9 +1,6 @@ package org.luxons.sevenwonders.game.boards import junit.framework.TestCase.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertSame -import org.junit.Assert.assertTrue import org.junit.Assume.assumeTrue import org.junit.Rule import org.junit.Test @@ -29,6 +26,9 @@ import org.luxons.sevenwonders.game.test.testBoard import org.luxons.sevenwonders.game.test.testCard import org.luxons.sevenwonders.game.test.testSettings import org.luxons.sevenwonders.game.test.testWonder +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue @RunWith(Theories::class) class BoardTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/MilitaryTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/MilitaryTest.kt index f3a50b00..dd2696f4 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/MilitaryTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/MilitaryTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.boards -import org.junit.Assert.assertEquals import org.junit.Rule import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.FromDataPoints @@ -9,7 +8,7 @@ import org.junit.experimental.theories.Theory import org.junit.rules.ExpectedException import org.junit.runner.RunWith import org.luxons.sevenwonders.game.boards.Military.UnknownAgeException -import java.util.HashMap +import kotlin.test.assertEquals @RunWith(Theories::class) class MilitaryTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/RelativeBoardPositionTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/RelativeBoardPositionTest.kt index e498119f..2038a676 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/RelativeBoardPositionTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/RelativeBoardPositionTest.kt @@ -1,11 +1,11 @@ package org.luxons.sevenwonders.game.boards -import org.junit.Assert.assertEquals import org.junit.Assume.assumeTrue import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.Theories import org.junit.experimental.theories.Theory import org.junit.runner.RunWith +import kotlin.test.assertEquals @RunWith(Theories::class) class RelativeBoardPositionTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/ScienceTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/ScienceTest.kt index 35e86219..80d6773d 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/ScienceTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/ScienceTest.kt @@ -1,12 +1,12 @@ package org.luxons.sevenwonders.game.boards -import org.junit.Assert.assertEquals 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.test.createScience +import kotlin.test.assertEquals @RunWith(Theories::class) class ScienceTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardBackTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardBackTest.kt index 8b2791a6..66ff7a0e 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardBackTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardBackTest.kt @@ -1,7 +1,7 @@ package org.luxons.sevenwonders.game.cards -import org.junit.Assert.assertEquals import org.junit.Test +import kotlin.test.assertEquals class CardBackTest { 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 6bc8da43..41c3c070 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 @@ -1,8 +1,6 @@ package org.luxons.sevenwonders.game.cards -import org.junit.Assert.assertEquals import org.junit.Test -import org.luxons.sevenwonders.game.Settings import org.luxons.sevenwonders.game.SimplePlayer import org.luxons.sevenwonders.game.api.Table import org.luxons.sevenwonders.game.boards.Board @@ -13,6 +11,7 @@ import org.luxons.sevenwonders.game.resources.noTransactions import org.luxons.sevenwonders.game.test.testCard import org.luxons.sevenwonders.game.test.testSettings import org.luxons.sevenwonders.game.wonders.Wonder +import kotlin.test.assertEquals class CardTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/DecksTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/DecksTest.kt index f0941412..d42fca63 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/DecksTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/DecksTest.kt @@ -1,8 +1,5 @@ package org.luxons.sevenwonders.game.cards -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertTrue import org.junit.Assume.assumeTrue import org.junit.Rule import org.junit.Test @@ -13,6 +10,9 @@ import org.junit.rules.ExpectedException import org.junit.runner.RunWith import org.luxons.sevenwonders.game.cards.Decks.CardNotFoundException import org.luxons.sevenwonders.game.test.sampleCards +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertTrue @RunWith(Theories::class) class DecksTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandRotationDirectionTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandRotationDirectionTest.kt index f7ddfb5d..4582c4a1 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandRotationDirectionTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandRotationDirectionTest.kt @@ -1,7 +1,7 @@ package org.luxons.sevenwonders.game.cards -import org.junit.Assert.assertEquals import org.junit.Test +import kotlin.test.assertEquals class HandRotationDirectionTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandsTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandsTest.kt index cc2da04b..eddb4d36 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandsTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandsTest.kt @@ -1,8 +1,5 @@ package org.luxons.sevenwonders.game.cards -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue import org.junit.Assume.assumeTrue import org.junit.Test import org.junit.experimental.theories.DataPoints @@ -13,6 +10,9 @@ import org.junit.runner.RunWith import org.luxons.sevenwonders.game.SimplePlayer import org.luxons.sevenwonders.game.test.sampleCards import org.luxons.sevenwonders.game.test.testTable +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue @RunWith(Theories::class) class HandsTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/RequirementsTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/RequirementsTest.kt index b7bfc935..e3e3a393 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/RequirementsTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/RequirementsTest.kt @@ -1,9 +1,5 @@ package org.luxons.sevenwonders.game.cards -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertSame -import org.junit.Assert.assertTrue import org.junit.Assume.assumeTrue import org.junit.Test import org.junit.experimental.theories.DataPoints @@ -21,6 +17,10 @@ import org.luxons.sevenwonders.game.test.createTransactions import org.luxons.sevenwonders.game.test.singleBoardPlayer import org.luxons.sevenwonders.game.test.testBoard import java.util.Arrays +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue @RunWith(Theories::class) class RequirementsTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionTest.kt index 44e81368..4317a933 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionTest.kt @@ -1,9 +1,9 @@ package org.luxons.sevenwonders.game.data -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotNull import org.junit.Test import org.luxons.sevenwonders.game.api.CustomizableSettings +import kotlin.test.assertEquals +import kotlin.test.assertNotNull class GameDefinitionTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt index 17e3b316..0b561938 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/definitions/WonderSidePickMethodTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.data.definitions -import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import org.junit.experimental.theories.DataPoints @@ -9,6 +8,7 @@ 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 { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.kt index 3ea3c959..dbd5a9a2 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.kt @@ -1,8 +1,8 @@ package org.luxons.sevenwonders.game.data.serializers +import com.github.salomonbrys.kotson.fromJson import com.google.gson.Gson import com.google.gson.GsonBuilder -import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import org.junit.experimental.theories.DataPoints @@ -14,6 +14,7 @@ import org.luxons.sevenwonders.game.effects.MilitaryReinforcements import org.luxons.sevenwonders.game.effects.ProductionIncrease import org.luxons.sevenwonders.game.effects.RawPointsIncrease import org.luxons.sevenwonders.game.resources.Production +import kotlin.test.assertEquals @RunWith(Theories::class) class NumericEffectSerializerTest { @@ -71,54 +72,54 @@ class NumericEffectSerializerTest { @Theory fun deserialize_militaryReinforcements(count: Int) { val reinforcements = MilitaryReinforcements(count) - assertEquals(reinforcements, gson.fromJson(count.toString(), MilitaryReinforcements::class.java)) + assertEquals(reinforcements, gson.fromJson<MilitaryReinforcements>(count.toString())) } @Theory fun deserialize_rawPointsIncrease(count: Int) { val points = RawPointsIncrease(count) - assertEquals(points, gson.fromJson(count.toString(), RawPointsIncrease::class.java)) + assertEquals(points, gson.fromJson<RawPointsIncrease>(count.toString())) } @Theory fun deserialize_goldIncrease(count: Int) { val goldIncrease = GoldIncrease(count) - assertEquals(goldIncrease, gson.fromJson(count.toString(), GoldIncrease::class.java)) + assertEquals(goldIncrease, gson.fromJson<GoldIncrease>(count.toString())) } @Test(expected = NumberFormatException::class) fun deserialize_militaryReinforcements_failOnEmptyString() { - gson.fromJson("\"\"", MilitaryReinforcements::class.java) + gson.fromJson<MilitaryReinforcements>("\"\"") } @Test(expected = NumberFormatException::class) fun deserialize_rawPointsIncrease_failOnEmptyString() { - gson.fromJson("\"\"", RawPointsIncrease::class.java) + gson.fromJson<RawPointsIncrease>("\"\"") } @Test(expected = NumberFormatException::class) fun deserialize_goldIncrease_failOnEmptyString() { - gson.fromJson("\"\"", GoldIncrease::class.java) + gson.fromJson<GoldIncrease>("\"\"") } @Test(expected = NumberFormatException::class) fun deserialize_militaryReinforcements_failOnNonNumericString() { - gson.fromJson("\"abc\"", MilitaryReinforcements::class.java) + gson.fromJson<MilitaryReinforcements>("\"abc\"") } @Test(expected = NumberFormatException::class) fun deserialize_rawPointsIncrease_failOnNonNumericString() { - gson.fromJson("\"abc\"", RawPointsIncrease::class.java) + gson.fromJson<RawPointsIncrease>("\"abc\"") } @Test(expected = NumberFormatException::class) fun deserialize_goldIncrease_failOnNonNumericString() { - gson.fromJson("\"abc\"", GoldIncrease::class.java) + gson.fromJson<GoldIncrease>("\"abc\"") } @Test(expected = IllegalArgumentException::class) fun deserialize_failOnUnknownType() { - gson.fromJson("\"2\"", ProductionIncrease::class.java) + gson.fromJson<ProductionIncrease>("\"2\"") } companion object { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.kt index 45013d78..8354ab21 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.kt @@ -1,10 +1,9 @@ package org.luxons.sevenwonders.game.data.serializers +import com.github.salomonbrys.kotson.fromJson import com.google.gson.Gson import com.google.gson.GsonBuilder import com.google.gson.reflect.TypeToken -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull import org.junit.Before import org.junit.Test import org.luxons.sevenwonders.game.effects.ProductionIncrease @@ -12,6 +11,9 @@ import org.luxons.sevenwonders.game.resources.MutableResources import org.luxons.sevenwonders.game.resources.Production import org.luxons.sevenwonders.game.resources.ResourceType import org.luxons.sevenwonders.game.resources.Resources +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertNull class ProductionIncreaseSerializerTest { @@ -57,69 +59,69 @@ class ProductionIncreaseSerializerTest { @Test fun serialize_emptyProdIncreaseAsNull() { val prodIncrease = ProductionIncrease(Production(), false) - assertEquals("null", gson.toJson(prodIncrease, ProductionIncrease::class.java)) + assertEquals("null", gson.toJson(prodIncrease)) } @Test fun serialize_singleType() { val prodIncrease = create(true, 1, 0, 0) - assertEquals("\"W\"", gson.toJson(prodIncrease, ProductionIncrease::class.java)) + assertEquals("\"W\"", gson.toJson(prodIncrease)) } @Test fun serialize_mixedTypes() { val prodIncrease = create(true, 1, 1, 1) - assertEquals("\"WSC\"", gson.toJson(prodIncrease, ProductionIncrease::class.java)) + assertEquals("\"WSC\"", gson.toJson(prodIncrease)) } @Test fun serialize_mixedTypes_notSellable() { val prodIncrease = create(false, 1, 1, 1) - assertEquals("\"(WSC)\"", gson.toJson(prodIncrease, ProductionIncrease::class.java)) + assertEquals("\"(WSC)\"", gson.toJson(prodIncrease)) } @Test fun serialize_choice2() { val prodIncrease = createChoice(true, ResourceType.WOOD, ResourceType.CLAY) - assertEquals("\"W/C\"", gson.toJson(prodIncrease, ProductionIncrease::class.java)) + assertEquals("\"W/C\"", gson.toJson(prodIncrease)) } @Test fun serialize_choice3() { val prodIncrease = createChoice(true, ResourceType.WOOD, ResourceType.ORE, ResourceType.CLAY) - assertEquals("\"W/O/C\"", gson.toJson(prodIncrease, ProductionIncrease::class.java)) + assertEquals("\"W/O/C\"", gson.toJson(prodIncrease)) } @Test fun serialize_choice3_notSellable() { val prodIncrease = createChoice(false, ResourceType.WOOD, ResourceType.ORE, ResourceType.CLAY) - assertEquals("\"(W/O/C)\"", gson.toJson(prodIncrease, ProductionIncrease::class.java)) + assertEquals("\"(W/O/C)\"", gson.toJson(prodIncrease)) } @Test fun serialize_choice2_unordered() { val prodIncrease = createChoice(true, ResourceType.CLAY, ResourceType.WOOD) - assertEquals("\"W/C\"", gson.toJson(prodIncrease, ProductionIncrease::class.java)) + assertEquals("\"W/C\"", gson.toJson(prodIncrease)) } @Test fun serialize_choice3_unordered() { val prodIncrease = createChoice(true, ResourceType.WOOD, ResourceType.CLAY, ResourceType.ORE) - assertEquals("\"W/O/C\"", gson.toJson(prodIncrease, ProductionIncrease::class.java)) + assertEquals("\"W/O/C\"", gson.toJson(prodIncrease)) } @Test(expected = IllegalArgumentException::class) fun serialize_failIfMultipleChoices() { val prodIncrease = createChoice(true, ResourceType.WOOD, ResourceType.CLAY) prodIncrease.production.addChoice(ResourceType.ORE, ResourceType.GLASS) - gson.toJson(prodIncrease, ProductionIncrease::class.java) + gson.toJson(prodIncrease) } @Test(expected = IllegalArgumentException::class) fun serialize_failIfMixedFixedAndChoices() { val prodIncrease = create(true, 1, 0, 0) prodIncrease.production.addChoice(ResourceType.WOOD, ResourceType.CLAY) - gson.toJson(prodIncrease, ProductionIncrease::class.java) + gson.toJson(prodIncrease) } @Test @@ -130,51 +132,57 @@ class ProductionIncreaseSerializerTest { @Test fun deserialize_emptyList() { val prodIncrease = ProductionIncrease(Production(), true) - assertEquals(prodIncrease, gson.fromJson("\"\"", ProductionIncrease::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"\"")) } - @Test(expected = IllegalArgumentException::class) + @Test fun deserialize_failOnGarbageString() { - gson.fromJson("\"this is garbage\"", ProductionIncrease::class.java) + assertFailsWith(IllegalArgumentException::class) { + gson.fromJson<ProductionIncrease>("\"this is garbage\"") + } } - @Test(expected = IllegalArgumentException::class) + @Test fun deserialize_failOnGarbageStringWithSlashes() { - gson.fromJson("\"this/is/garbage\"", ProductionIncrease::class.java) + assertFailsWith(IllegalArgumentException::class) { + gson.fromJson<ProductionIncrease>("\"this/is/garbage\"") + } } @Test fun deserialize_singleType() { val prodIncrease = create(true, 1, 0, 0) - assertEquals(prodIncrease, gson.fromJson("\"W\"", ProductionIncrease::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"W\"")) } @Test fun deserialize_multipleTimesSameType_notSellable() { val prodIncrease = create(false, 3, 0, 0) - assertEquals(prodIncrease, gson.fromJson("\"(WWW)\"", ProductionIncrease::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"(WWW)\"")) } @Test fun deserialize_mixedTypes() { val prodIncrease = create(true, 1, 1, 1) - assertEquals(prodIncrease, gson.fromJson("\"WCS\"", ProductionIncrease::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"WCS\"")) } @Test fun deserialize_choice2() { val prodIncrease = createChoice(true, ResourceType.WOOD, ResourceType.CLAY) - assertEquals(prodIncrease, gson.fromJson("\"W/C\"", ProductionIncrease::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"W/C\"")) } @Test fun deserialize_choice3_notSellable() { val prodIncrease = createChoice(false, ResourceType.WOOD, ResourceType.ORE, ResourceType.CLAY) - assertEquals(prodIncrease, gson.fromJson("\"(W/O/C)\"", ProductionIncrease::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"(W/O/C)\"")) } - @Test(expected = IllegalArgumentException::class) + @Test fun deserialize_failOnMultipleResourcesInChoice() { - gson.fromJson("\"W/SS/C\"", ProductionIncrease::class.java) + assertFailsWith(IllegalArgumentException::class) { + gson.fromJson<ProductionIncrease>("\"W/SS/C\"") + } } } diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionSerializerTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionSerializerTest.kt index 8977255e..82d99fb8 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionSerializerTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionSerializerTest.kt @@ -1,16 +1,17 @@ package org.luxons.sevenwonders.game.data.serializers +import com.github.salomonbrys.kotson.fromJson import com.google.gson.Gson import com.google.gson.GsonBuilder import com.google.gson.reflect.TypeToken -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull import org.junit.Before import org.junit.Test import org.luxons.sevenwonders.game.resources.MutableResources import org.luxons.sevenwonders.game.resources.Production import org.luxons.sevenwonders.game.resources.ResourceType import org.luxons.sevenwonders.game.resources.Resources +import kotlin.test.assertEquals +import kotlin.test.assertNull class ProductionSerializerTest { @@ -55,69 +56,69 @@ class ProductionSerializerTest { @Test fun serialize_emptyProdIncreaseAsNull() { val prodIncrease = Production() - assertEquals("null", gson.toJson(prodIncrease, Production::class.java)) + assertEquals("null", gson.toJson(prodIncrease)) } @Test fun serialize_singleType() { val prodIncrease = create(1, 0, 0) - assertEquals("\"W\"", gson.toJson(prodIncrease, Production::class.java)) + assertEquals("\"W\"", gson.toJson(prodIncrease)) } @Test fun serialize_multipleTimesSameType() { val prodIncrease = create(3, 0, 0) - assertEquals("\"WWW\"", gson.toJson(prodIncrease, Production::class.java)) + assertEquals("\"WWW\"", gson.toJson(prodIncrease)) } @Test fun serialize_mixedTypes() { val prodIncrease = create(1, 1, 1) - assertEquals("\"WSC\"", gson.toJson(prodIncrease, Production::class.java)) + assertEquals("\"WSC\"", gson.toJson(prodIncrease)) } @Test fun serialize_mixedTypesMultiple() { val prodIncrease = create(2, 1, 2) - assertEquals("\"WWSCC\"", gson.toJson(prodIncrease, Production::class.java)) + assertEquals("\"WWSCC\"", gson.toJson(prodIncrease)) } @Test fun serialize_choice2() { val prodIncrease = createChoice(ResourceType.WOOD, ResourceType.CLAY) - assertEquals("\"W/C\"", gson.toJson(prodIncrease, Production::class.java)) + assertEquals("\"W/C\"", gson.toJson(prodIncrease)) } @Test fun serialize_choice3() { val prodIncrease = createChoice(ResourceType.WOOD, ResourceType.ORE, ResourceType.CLAY) - assertEquals("\"W/O/C\"", gson.toJson(prodIncrease, Production::class.java)) + assertEquals("\"W/O/C\"", gson.toJson(prodIncrease)) } @Test fun serialize_choice2_unordered() { val prodIncrease = createChoice(ResourceType.CLAY, ResourceType.WOOD) - assertEquals("\"W/C\"", gson.toJson(prodIncrease, Production::class.java)) + assertEquals("\"W/C\"", gson.toJson(prodIncrease)) } @Test fun serialize_choice3_unordered() { val prodIncrease = createChoice(ResourceType.WOOD, ResourceType.CLAY, ResourceType.ORE) - assertEquals("\"W/O/C\"", gson.toJson(prodIncrease, Production::class.java)) + assertEquals("\"W/O/C\"", gson.toJson(prodIncrease)) } @Test(expected = IllegalArgumentException::class) fun serialize_failIfMultipleChoices() { val production = createChoice(ResourceType.WOOD, ResourceType.CLAY) production.addChoice(ResourceType.ORE, ResourceType.GLASS) - gson.toJson(production, Production::class.java) + gson.toJson(production) } @Test(expected = IllegalArgumentException::class) fun serialize_failIfMixedFixedAndChoices() { val production = create(1, 0, 0) production.addChoice(ResourceType.WOOD, ResourceType.CLAY) - gson.toJson(production, Production::class.java) + gson.toJson(production) } @Test @@ -128,69 +129,69 @@ class ProductionSerializerTest { @Test fun deserialize_emptyList() { val prodIncrease = Production() - assertEquals(prodIncrease, gson.fromJson("\"\"", Production::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"\"")) } @Test(expected = IllegalArgumentException::class) fun deserialize_failOnGarbageString() { - gson.fromJson("\"this is garbage\"", Production::class.java) + gson.fromJson<Production>("\"this is garbage\"") } @Test(expected = IllegalArgumentException::class) fun deserialize_failOnGarbageStringWithSlashes() { - gson.fromJson("\"this/is/garbage\"", Production::class.java) + gson.fromJson<Production>("\"this/is/garbage\"") } @Test fun deserialize_singleType() { val prodIncrease = create(1, 0, 0) - assertEquals(prodIncrease, gson.fromJson("\"W\"", Production::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"W\"")) } @Test fun deserialize_multipleTimesSameType() { val prodIncrease = create(3, 0, 0) - assertEquals(prodIncrease, gson.fromJson("\"WWW\"", Production::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"WWW\"")) } @Test fun deserialize_mixedTypes() { val prodIncrease = create(1, 1, 1) - assertEquals(prodIncrease, gson.fromJson("\"WCS\"", Production::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"WCS\"")) } @Test fun deserialize_mixedTypes_unordered() { val prodIncrease = create(1, 3, 2) - assertEquals(prodIncrease, gson.fromJson("\"SCWCSS\"", Production::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"SCWCSS\"")) } @Test fun deserialize_choice2() { val prodIncrease = createChoice(ResourceType.WOOD, ResourceType.CLAY) - assertEquals(prodIncrease, gson.fromJson("\"W/C\"", Production::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"W/C\"")) } @Test fun deserialize_choice3() { val prodIncrease = createChoice(ResourceType.WOOD, ResourceType.ORE, ResourceType.CLAY) - assertEquals(prodIncrease, gson.fromJson("\"W/O/C\"", Production::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"W/O/C\"")) } @Test fun deserialize_choice2_unordered() { val prodIncrease = createChoice(ResourceType.CLAY, ResourceType.WOOD) - assertEquals(prodIncrease, gson.fromJson("\"W/C\"", Production::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"W/C\"")) } @Test fun deserialize_choice3_unordered() { val prodIncrease = createChoice(ResourceType.WOOD, ResourceType.CLAY, ResourceType.ORE) - assertEquals(prodIncrease, gson.fromJson("\"W/O/C\"", Production::class.java)) + assertEquals(prodIncrease, gson.fromJson("\"W/O/C\"")) } @Test(expected = IllegalArgumentException::class) fun deserialize_failOnMultipleResourcesInChoice() { - gson.fromJson("\"W/SS/C\"", Production::class.java) + gson.fromJson<Production>("\"W/SS/C\"") } } diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializerTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializerTest.kt index a399a31c..eee04047 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializerTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializerTest.kt @@ -1,12 +1,13 @@ package org.luxons.sevenwonders.game.data.serializers +import com.github.salomonbrys.kotson.fromJson import com.google.gson.Gson import com.google.gson.GsonBuilder -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull import org.junit.Before import org.junit.Test import org.luxons.sevenwonders.game.resources.ResourceType +import kotlin.test.assertEquals +import kotlin.test.assertNull class ResourceTypeSerializerTest { @@ -19,7 +20,7 @@ class ResourceTypeSerializerTest { @Test fun serialize_useSymbolForEachType() { - for (type in ResourceType.values()) { + ResourceType.values().forEach { type -> val expectedJson = "\"" + type.symbol + "\"" assertEquals(expectedJson, gson.toJson(type)) } @@ -27,9 +28,9 @@ class ResourceTypeSerializerTest { @Test fun deserialize_useSymbolForEachType() { - for (type in ResourceType.values()) { + ResourceType.values().forEach { type -> val typeInJson = "\"" + type.symbol + "\"" - assertEquals(type, gson.fromJson(typeInJson, ResourceType::class.java)) + assertEquals(type, gson.fromJson(typeInJson)) } } @@ -40,11 +41,11 @@ class ResourceTypeSerializerTest { @Test(expected = IllegalArgumentException::class) fun deserialize_failsOnEmptyString() { - gson.fromJson("\"\"", ResourceType::class.java) + gson.fromJson<ResourceType>("\"\"") } @Test(expected = IllegalArgumentException::class) fun deserialize_failsOnGarbageString() { - gson.fromJson("\"thisisgarbage\"", ResourceType::class.java) + gson.fromJson<ResourceType>("\"thisisgarbage\"") } } diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypesSerializerTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypesSerializerTest.kt index 63d8e5c7..8c1b421d 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypesSerializerTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypesSerializerTest.kt @@ -1,98 +1,80 @@ package org.luxons.sevenwonders.game.data.serializers +import com.github.salomonbrys.kotson.fromJson +import com.github.salomonbrys.kotson.typeToken +import com.github.salomonbrys.kotson.typedToJson import com.google.gson.Gson import com.google.gson.GsonBuilder -import com.google.gson.reflect.TypeToken -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull import org.junit.Before import org.junit.Test import org.luxons.sevenwonders.game.resources.ResourceType -import java.lang.reflect.Type -import java.util.ArrayList +import kotlin.test.assertEquals +import kotlin.test.assertNull class ResourceTypesSerializerTest { private lateinit var gson: Gson - + @Before fun setUp() { - gson = GsonBuilder().registerTypeAdapter(createListTypeToken(), ResourceTypesSerializer()).create() - } - - private fun createListTypeToken(): Type { - return object : TypeToken<List<ResourceType>>() {}.type + gson = GsonBuilder().registerTypeAdapter(typeToken<List<ResourceType>>(), ResourceTypesSerializer()).create() } @Test fun serialize_null() { - assertEquals("null", gson.toJson(null, createListTypeToken())) + assertEquals("null", gson.toJson(null, typeToken<List<ResourceType>>())) } @Test fun serialize_emptyList() { - val types = ArrayList<ResourceType>() - assertEquals("\"\"", gson.toJson(types, createListTypeToken())) + val types = emptyList<ResourceType>() + assertEquals("\"\"", gson.typedToJson(types)) } @Test fun serialize_singleType() { - val types = ArrayList<ResourceType>() - types.add(ResourceType.WOOD) - assertEquals("\"W\"", gson.toJson(types, createListTypeToken())) + val types = listOf(ResourceType.WOOD) + assertEquals("\"W\"", gson.typedToJson(types)) } @Test fun serialize_multipleTimesSameType() { - val types = ArrayList<ResourceType>() - types.add(ResourceType.WOOD) - types.add(ResourceType.WOOD) - types.add(ResourceType.WOOD) - assertEquals("\"WWW\"", gson.toJson(types, createListTypeToken())) + val types = List(3) { ResourceType.WOOD } + assertEquals("\"WWW\"", gson.typedToJson(types)) } @Test fun serialize_mixedTypes() { - val types = ArrayList<ResourceType>() - types.add(ResourceType.WOOD) - types.add(ResourceType.CLAY) - types.add(ResourceType.STONE) - assertEquals("\"WCS\"", gson.toJson(types, createListTypeToken())) + val types = listOf(ResourceType.WOOD, ResourceType.CLAY, ResourceType.STONE) + assertEquals("\"WCS\"", gson.typedToJson(types)) } @Test fun deserialize_null() { - assertNull(gson.fromJson("null", createListTypeToken())) + assertNull(gson.fromJson("null", typeToken<List<ResourceType>>())) } @Test fun deserialize_emptyList() { - val types = ArrayList<ResourceType>() - assertEquals(types, gson.fromJson("\"\"", createListTypeToken())) + val types = emptyList<ResourceType>() + assertEquals(types, gson.fromJson("\"\"")) } @Test fun deserialize_singleType() { - val types = ArrayList<ResourceType>() - types.add(ResourceType.WOOD) - assertEquals(types, gson.fromJson("\"W\"", createListTypeToken())) + val types = listOf(ResourceType.WOOD) + assertEquals(types, gson.fromJson("\"W\"")) } @Test fun deserialize_multipleTimesSameType() { - val types = ArrayList<ResourceType>() - types.add(ResourceType.WOOD) - types.add(ResourceType.WOOD) - types.add(ResourceType.WOOD) - assertEquals(types, gson.fromJson("\"WWW\"", createListTypeToken())) + val types = List(3) { ResourceType.WOOD } + assertEquals(types, gson.fromJson("\"WWW\"")) } @Test fun deserialize_mixedTypes() { - val types = ArrayList<ResourceType>() - types.add(ResourceType.WOOD) - types.add(ResourceType.CLAY) - types.add(ResourceType.STONE) - assertEquals(types, gson.fromJson("\"WCS\"", createListTypeToken())) + val types = listOf(ResourceType.WOOD, ResourceType.CLAY, ResourceType.STONE) + assertEquals(types, gson.fromJson("\"WCS\"")) } } diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializerTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializerTest.kt index ba4793c0..c146a948 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializerTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializerTest.kt @@ -1,9 +1,8 @@ package org.luxons.sevenwonders.game.data.serializers +import com.github.salomonbrys.kotson.fromJson import com.google.gson.Gson import com.google.gson.GsonBuilder -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull import org.junit.Before import org.junit.Test import org.luxons.sevenwonders.game.resources.MutableResources @@ -13,6 +12,8 @@ import org.luxons.sevenwonders.game.resources.ResourceType.WOOD import org.luxons.sevenwonders.game.resources.Resources import org.luxons.sevenwonders.game.resources.emptyResources import org.luxons.sevenwonders.game.resources.resourcesOf +import kotlin.test.assertEquals +import kotlin.test.assertNull class ResourcesSerializerTest { @@ -69,30 +70,30 @@ class ResourcesSerializerTest { @Test fun deserialize_emptyList() { val resources = emptyResources() - assertEquals(resources, gson.fromJson("\"\"", Resources::class.java)) + assertEquals(resources, gson.fromJson("\"\"")) } @Test fun deserialize_singleType() { val resources = resourcesOf(WOOD) - assertEquals(resources, gson.fromJson("\"W\"", Resources::class.java)) + assertEquals(resources, gson.fromJson("\"W\"")) } @Test fun deserialize_multipleTimesSameType() { val resources = resourcesOf(WOOD to 3) - assertEquals(resources, gson.fromJson("\"WWW\"", Resources::class.java)) + assertEquals(resources, gson.fromJson("\"WWW\"")) } @Test fun deserialize_mixedTypes() { val resources = resourcesOf(WOOD, CLAY, STONE) - assertEquals(resources, gson.fromJson("\"WCS\"", Resources::class.java)) + assertEquals(resources, gson.fromJson("\"WCS\"")) } @Test fun deserialize_mixedTypes_unordered() { val resources = resourcesOf(WOOD to 1, CLAY to 2, STONE to 3) - assertEquals(resources, gson.fromJson("\"SCWCSS\"", Resources::class.java)) + assertEquals(resources, gson.fromJson("\"SCWCSS\"")) } } diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.kt index 75bd5d61..1c95bb36 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.kt @@ -1,14 +1,15 @@ package org.luxons.sevenwonders.game.data.serializers +import com.github.salomonbrys.kotson.fromJson import com.google.gson.Gson import com.google.gson.GsonBuilder -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotNull import org.junit.Before import org.junit.Test import org.luxons.sevenwonders.game.boards.ScienceType import org.luxons.sevenwonders.game.effects.ScienceProgress import org.luxons.sevenwonders.game.test.createScienceProgress +import kotlin.test.assertEquals +import kotlin.test.assertNotNull private const val TABLET_STR = "\"TABLET\"" private const val COMPASS_STR = "\"COMPASS\"" @@ -91,17 +92,17 @@ class ScienceProgressSerializerTest { @Test(expected = IllegalArgumentException::class) fun deserialize_failOnEmptyString() { - gson.fromJson("\"\"", ScienceProgress::class.java) + gson.fromJson<ScienceProgress>("\"\"") } @Test(expected = IllegalArgumentException::class) fun deserialize_failOnGarbageString() { - gson.fromJson("thisisgarbage", ScienceProgress::class.java) + gson.fromJson<ScienceProgress>("thisisgarbage") } @Test fun deserialize_compass() { - val progress = gson.fromJson(COMPASS_STR, ScienceProgress::class.java) + val progress = gson.fromJson<ScienceProgress>(COMPASS_STR) assertNotNull(progress.science) assertEquals(1, progress.science.getQuantity(ScienceType.COMPASS)) assertEquals(0, progress.science.getQuantity(ScienceType.WHEEL)) @@ -111,7 +112,7 @@ class ScienceProgressSerializerTest { @Test fun deserialize_wheel() { - val progress = gson.fromJson(WHEEL_STR, ScienceProgress::class.java) + val progress = gson.fromJson<ScienceProgress>(WHEEL_STR) assertNotNull(progress.science) assertEquals(0, progress.science.getQuantity(ScienceType.COMPASS)) assertEquals(1, progress.science.getQuantity(ScienceType.WHEEL)) @@ -121,7 +122,7 @@ class ScienceProgressSerializerTest { @Test fun deserialize_tablet() { - val progress = gson.fromJson(TABLET_STR, ScienceProgress::class.java) + val progress = gson.fromJson<ScienceProgress>(TABLET_STR) assertNotNull(progress.science) assertEquals(0, progress.science.getQuantity(ScienceType.COMPASS)) assertEquals(0, progress.science.getQuantity(ScienceType.WHEEL)) @@ -131,7 +132,7 @@ class ScienceProgressSerializerTest { @Test fun deserialize_joker() { - val progress = gson.fromJson(JOKER_STR, ScienceProgress::class.java) + val progress = gson.fromJson<ScienceProgress>(JOKER_STR) assertNotNull(progress.science) assertEquals(0, progress.science.getQuantity(ScienceType.COMPASS)) assertEquals(0, progress.science.getQuantity(ScienceType.WHEEL)) diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt index 535a5a97..7c8a7e95 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.effects -import org.junit.Assert.assertEquals import org.junit.Before import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.Theories @@ -14,6 +13,7 @@ import org.luxons.sevenwonders.game.cards.CardBack import org.luxons.sevenwonders.game.cards.Color import org.luxons.sevenwonders.game.test.addCards import org.luxons.sevenwonders.game.test.testTable +import kotlin.test.assertEquals @RunWith(Theories::class) class BonusPerBoardElementTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/DiscountTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/DiscountTest.kt index 7247ccdc..d92c8d24 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/DiscountTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/DiscountTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.effects -import org.junit.Assert.assertEquals import org.junit.Assume import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.Theories @@ -10,6 +9,7 @@ import org.luxons.sevenwonders.game.resources.Provider import org.luxons.sevenwonders.game.resources.ResourceType import org.luxons.sevenwonders.game.test.createTransactions import org.luxons.sevenwonders.game.test.testBoard +import kotlin.test.assertEquals @RunWith(Theories::class) class DiscountTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.kt index 96a4aa2a..993cc273 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.effects -import org.junit.Assert.assertEquals import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.Theories import org.junit.experimental.theories.Theory @@ -9,6 +8,7 @@ import org.luxons.sevenwonders.game.SimplePlayer import org.luxons.sevenwonders.game.resources.ResourceType import org.luxons.sevenwonders.game.test.testBoard import org.luxons.sevenwonders.game.test.testTable +import kotlin.test.assertEquals @RunWith(Theories::class) class GoldIncreaseTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.kt index 7e66fd4b..0d5765da 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.effects -import org.junit.Assert.assertEquals import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.Theories import org.junit.experimental.theories.Theory @@ -9,6 +8,7 @@ import org.luxons.sevenwonders.game.SimplePlayer import org.luxons.sevenwonders.game.resources.ResourceType import org.luxons.sevenwonders.game.test.testBoard import org.luxons.sevenwonders.game.test.testTable +import kotlin.test.assertEquals @RunWith(Theories::class) class MilitaryReinforcementsTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.kt index d454e12d..c016ccc9 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.kt @@ -1,8 +1,5 @@ package org.luxons.sevenwonders.game.effects -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.Theories import org.junit.experimental.theories.Theory @@ -13,6 +10,9 @@ import org.luxons.sevenwonders.game.resources.resourcesOf import org.luxons.sevenwonders.game.test.fixedProduction import org.luxons.sevenwonders.game.test.testBoard import org.luxons.sevenwonders.game.test.testTable +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue @RunWith(Theories::class) class ProductionIncreaseTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.kt index 0867789b..9cb10562 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.kt @@ -1,12 +1,12 @@ package org.luxons.sevenwonders.game.effects -import org.junit.Assert.assertEquals 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.SimplePlayer import org.luxons.sevenwonders.game.test.testTable +import kotlin.test.assertEquals @RunWith(Theories::class) class RawPointsIncreaseTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgressTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgressTest.kt index 1223578a..7e566a8c 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgressTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgressTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.effects -import org.junit.Assert.assertEquals import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.Theories import org.junit.experimental.theories.Theory @@ -10,6 +9,7 @@ import org.luxons.sevenwonders.game.resources.ResourceType import org.luxons.sevenwonders.game.test.createScience import org.luxons.sevenwonders.game.test.createScienceProgress import org.luxons.sevenwonders.game.test.testBoard +import kotlin.test.assertEquals @RunWith(Theories::class) class ScienceProgressTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt index 7b589bdc..41d3d51b 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt @@ -1,7 +1,5 @@ package org.luxons.sevenwonders.game.effects -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue import org.junit.Assume import org.junit.Test import org.junit.experimental.theories.DataPoints @@ -14,6 +12,8 @@ import org.luxons.sevenwonders.game.cards.Card import org.luxons.sevenwonders.game.cards.Color import org.luxons.sevenwonders.game.test.createGuildCard import org.luxons.sevenwonders.game.test.testTable +import kotlin.test.assertEquals +import kotlin.test.assertTrue @RunWith(Theories::class) class SpecialAbilityActivationTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.kt index 62213788..acced6be 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.kt @@ -1,7 +1,5 @@ package org.luxons.sevenwonders.game.moves -import org.junit.Assert.assertEquals -import org.junit.Assert.fail import org.junit.Test import org.luxons.sevenwonders.game.PlayerContext import org.luxons.sevenwonders.game.Settings @@ -12,6 +10,8 @@ import org.luxons.sevenwonders.game.test.sampleCards import org.luxons.sevenwonders.game.test.testCard import org.luxons.sevenwonders.game.test.testSettings import org.luxons.sevenwonders.game.test.testTable +import kotlin.test.assertEquals +import kotlin.test.fail class BuildWonderMoveTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.kt index 032d8a1a..e6751776 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.resources -import org.junit.Assert.assertEquals import org.junit.Test import org.luxons.sevenwonders.game.SimplePlayer import org.luxons.sevenwonders.game.api.Table @@ -16,6 +15,7 @@ import org.luxons.sevenwonders.game.test.createTransactions import org.luxons.sevenwonders.game.test.testBoard import org.luxons.sevenwonders.game.test.testTable import java.util.Arrays +import kotlin.test.assertEquals class BestPriceCalculatorTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ProductionTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ProductionTest.kt index 95913806..0e865921 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ProductionTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ProductionTest.kt @@ -1,8 +1,5 @@ package org.luxons.sevenwonders.game.resources -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import org.luxons.sevenwonders.game.resources.ResourceType.CLAY @@ -14,6 +11,9 @@ import org.luxons.sevenwonders.game.resources.ResourceType.STONE import org.luxons.sevenwonders.game.resources.ResourceType.WOOD import java.util.EnumSet import java.util.HashSet +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue class ProductionTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ResourceTransactionsTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ResourceTransactionsTest.kt index 33d69428..7e6d7816 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ResourceTransactionsTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ResourceTransactionsTest.kt @@ -1,10 +1,10 @@ package org.luxons.sevenwonders.game.resources -import org.junit.Assert.assertEquals import org.junit.Test import org.luxons.sevenwonders.game.resources.ResourceType.CLAY import org.luxons.sevenwonders.game.resources.ResourceType.WOOD import org.luxons.sevenwonders.game.test.createTransaction +import kotlin.test.assertEquals class ResourceTransactionsTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ResourcesTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ResourcesTest.kt index db19e025..ba20bc62 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ResourcesTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ResourcesTest.kt @@ -1,8 +1,5 @@ package org.luxons.sevenwonders.game.resources -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.junit.rules.ExpectedException @@ -14,6 +11,9 @@ import org.luxons.sevenwonders.game.resources.ResourceType.PAPYRUS import org.luxons.sevenwonders.game.resources.ResourceType.STONE import org.luxons.sevenwonders.game.resources.ResourceType.WOOD import java.util.NoSuchElementException +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue class ResourcesTest { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/TradingRulesTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/TradingRulesTest.kt index 6da59d5f..38953529 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/TradingRulesTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/TradingRulesTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.game.resources -import org.junit.Assert.assertEquals import org.junit.Assume.assumeTrue import org.junit.experimental.theories.DataPoints import org.junit.experimental.theories.Theories @@ -8,6 +7,7 @@ import org.junit.experimental.theories.Theory import org.junit.runner.RunWith import org.luxons.sevenwonders.game.test.createTransaction import org.luxons.sevenwonders.game.test.createTransactions +import kotlin.test.assertEquals @RunWith(Theories::class) class TradingRulesTest { 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 index 40f45201..491d13fb 100644 --- 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 @@ -1,10 +1,10 @@ package org.luxons.sevenwonders.game.wonders -import org.junit.Assert.assertEquals -import org.junit.Assert.fail import org.junit.Test import org.luxons.sevenwonders.game.cards.CardBack import org.luxons.sevenwonders.game.test.testWonder +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith class WonderTest { @@ -26,11 +26,9 @@ class WonderTest { wonder.placeCard(CardBack("img")) wonder.placeCard(CardBack("img")) wonder.placeCard(CardBack("img")) - try { + + assertFailsWith(IllegalStateException::class) { wonder.placeCard(CardBack("img")) - fail() - } catch (e: IllegalStateException) { - // expected exception because there is no 4th level in this wonder } } } |