summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt21
-rw-r--r--backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt36
-rw-r--r--backend/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt61
-rw-r--r--backend/src/test/kotlin/org/luxons/sevenwonders/repositories/LobbyRepositoryTest.kt13
-rw-r--r--backend/src/test/kotlin/org/luxons/sevenwonders/repositories/PlayerRepositoryTest.kt13
-rw-r--r--backend/src/test/kotlin/org/luxons/sevenwonders/validation/DestinationAccessValidatorTest.kt25
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/BoardTest.kt19
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/boards/MilitaryTest.kt12
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/DecksTest.kt42
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandsTest.kt6
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.kt52
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.kt12
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionSerializerTest.kt34
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializerTest.kt13
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.kt53
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt10
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.kt14
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/ResourcesTest.kt12
18 files changed, 281 insertions, 167 deletions
diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt
index 98506fd0..343b7f34 100644
--- a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt
+++ b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt
@@ -11,6 +11,7 @@ import org.luxons.sevenwonders.repositories.PlayerNotFoundException
import org.luxons.sevenwonders.repositories.PlayerRepository
import org.luxons.sevenwonders.test.mockSimpMessagingTemplate
import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertTrue
@@ -54,15 +55,17 @@ class GameBrowserControllerTest {
assertEquals(player.toDTO(principal.name), lobby.players[0])
}
- @Test(expected = PlayerNotFoundException::class)
+ @Test
fun createGame_failsForUnknownPlayer() {
val principal = TestPrincipal("unknown")
-
val action = CreateGameAction("Test Game")
- gameBrowserController.createGame(action, principal)
+
+ assertFailsWith<PlayerNotFoundException> {
+ gameBrowserController.createGame(action, principal)
+ }
}
- @Test(expected = UserAlreadyInGameException::class)
+ @Test
fun createGame_failsWhenAlreadyInGame() {
playerRepository.createOrUpdate("testuser", "Test User")
val principal = TestPrincipal("testuser")
@@ -75,7 +78,9 @@ class GameBrowserControllerTest {
val createGameAction2 = CreateGameAction("Test Game 2")
// already in a game
- gameBrowserController.createGame(createGameAction2, principal)
+ assertFailsWith<UserAlreadyInGameException> {
+ gameBrowserController.createGame(createGameAction2, principal)
+ }
}
@Test
@@ -97,7 +102,7 @@ class GameBrowserControllerTest {
assertEquals(joiner.toDTO(joinerPrincipal.name), joinedLobby.players[1])
}
- @Test(expected = UserAlreadyInGameException::class)
+ @Test
fun joinGame_failsWhenAlreadyInGame() {
playerRepository.createOrUpdate("testowner", "Test User Owner")
val ownerPrincipal = TestPrincipal("testowner")
@@ -112,6 +117,8 @@ class GameBrowserControllerTest {
// joins the game
gameBrowserController.joinGame(joinGameAction, joinerPrincipal)
// should fail because already in a game
- gameBrowserController.joinGame(joinGameAction, joinerPrincipal)
+ assertFailsWith<UserAlreadyInGameException> {
+ gameBrowserController.joinGame(joinGameAction, joinerPrincipal)
+ }
}
}
diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt
index 6e417970..a140e000 100644
--- a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt
+++ b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt
@@ -17,6 +17,7 @@ import org.luxons.sevenwonders.repositories.PlayerRepository
import org.luxons.sevenwonders.test.mockSimpMessagingTemplate
import java.util.HashMap
import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertSame
import kotlin.test.assertTrue
@@ -49,17 +50,23 @@ class LobbyControllerTest {
assertFalse(owner.isInGame)
}
- @Test(expected = PlayerNotFoundException::class)
+ @Test
fun leave_failsWhenPlayerDoesNotExist() {
val principal = TestPrincipal("I don't exist")
- lobbyController.leave(principal)
+
+ assertFailsWith<PlayerNotFoundException> {
+ lobbyController.leave(principal)
+ }
}
- @Test(expected = PlayerNotInLobbyException::class)
+ @Test
fun leave_failsWhenNotInLobby() {
playerRepository.createOrUpdate("testuser", "Test User")
val principal = TestPrincipal("testuser")
- lobbyController.leave(principal)
+
+ assertFailsWith<PlayerNotInLobbyException> {
+ lobbyController.leave(principal)
+ }
}
@Test
@@ -111,7 +118,7 @@ class LobbyControllerTest {
assertEquals(reorderedPlayers, lobby.getPlayers())
}
- @Test(expected = PlayerIsNotOwnerException::class)
+ @Test
fun reorderPlayers_failsForPeasant() {
val player = playerRepository.createOrUpdate("testuser", "Test User")
val lobby = lobbyRepository.create("Test Game", player)
@@ -124,7 +131,10 @@ class LobbyControllerTest {
val reorderPlayersAction = ReorderPlayersAction(playerNames)
val principal = TestPrincipal("testuser2")
- lobbyController.reorderPlayers(reorderPlayersAction, principal)
+
+ assertFailsWith<PlayerIsNotOwnerException> {
+ lobbyController.reorderPlayers(reorderPlayersAction, principal)
+ }
}
@Test
@@ -147,7 +157,7 @@ class LobbyControllerTest {
assertEquals(newSettings, lobby.settings)
}
- @Test(expected = PlayerIsNotOwnerException::class)
+ @Test
fun updateSettings_failsForPeasant() {
val player = playerRepository.createOrUpdate("testuser", "Test User")
val lobby = lobbyRepository.create("Test Game", player)
@@ -158,7 +168,10 @@ class LobbyControllerTest {
val updateSettingsAction = UpdateSettingsAction(CustomizableSettings())
val principal = TestPrincipal("testuser2")
- lobbyController.updateSettings(updateSettingsAction, principal)
+
+ assertFailsWith<PlayerIsNotOwnerException> {
+ lobbyController.updateSettings(updateSettingsAction, principal)
+ }
}
@Test
@@ -176,7 +189,7 @@ class LobbyControllerTest {
assertSame(State.PLAYING, lobby.state)
}
- @Test(expected = PlayerIsNotOwnerException::class)
+ @Test
fun startGame_failsForPeasant() {
val player = playerRepository.createOrUpdate("testuser", "Test User")
val lobby = lobbyRepository.create("Test Game", player)
@@ -185,7 +198,10 @@ class LobbyControllerTest {
addPlayer(lobby, "testuser3")
val principal = TestPrincipal("testuser2")
- lobbyController.startGame(principal)
+
+ assertFailsWith<PlayerIsNotOwnerException> {
+ lobbyController.startGame(principal)
+ }
}
private fun addPlayer(lobby: Lobby, username: String): Player {
diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt
index 98e154da..967a97e2 100644
--- a/backend/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt
+++ b/backend/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt
@@ -3,12 +3,10 @@ package org.luxons.sevenwonders.lobby
import org.junit.Assume.assumeTrue
import org.junit.Before
import org.junit.BeforeClass
-import org.junit.Rule
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.rules.ExpectedException
import org.junit.runner.RunWith
import org.luxons.sevenwonders.game.api.CustomizableSettings
import org.luxons.sevenwonders.game.data.GameDefinition
@@ -19,6 +17,7 @@ import org.luxons.sevenwonders.lobby.Lobby.PlayerOverflowException
import org.luxons.sevenwonders.lobby.Lobby.PlayerUnderflowException
import org.luxons.sevenwonders.lobby.Lobby.UnknownPlayerException
import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertSame
@@ -27,10 +26,6 @@ import kotlin.test.assertTrue
@RunWith(Theories::class)
class LobbyTest {
- @JvmField
- @Rule
- var thrown = ExpectedException.none()
-
private lateinit var gameOwner: Player
private lateinit var lobby: Lobby
@@ -95,26 +90,32 @@ class LobbyTest {
assertSame(lobby, player.lobby)
}
- @Test(expected = PlayerNameAlreadyUsedException::class)
+ @Test
fun addPlayer_failsOnSameName() {
val player = Player("testuser", "Test User")
val player2 = Player("testuser2", "Test User")
lobby.addPlayer(player)
- lobby.addPlayer(player2)
+ assertFailsWith<PlayerNameAlreadyUsedException> {
+ lobby.addPlayer(player2)
+ }
}
- @Test(expected = PlayerOverflowException::class)
+ @Test
fun addPlayer_playerOverflowWhenTooMany() {
- // the owner + the max number gives an overflow
- addPlayers(gameDefinition.maxPlayers)
+ assertFailsWith<PlayerOverflowException> {
+ // the owner + the max number gives an overflow
+ addPlayers(gameDefinition.maxPlayers)
+ }
}
- @Test(expected = GameAlreadyStartedException::class)
+ @Test
fun addPlayer_failWhenGameStarted() {
// total with owner is the minimum
addPlayers(gameDefinition.minPlayers - 1)
lobby.startGame()
- lobby.addPlayer(Player("soonerNextTime", "The Late Guy"))
+ assertFailsWith<GameAlreadyStartedException> {
+ lobby.addPlayer(Player("soonerNextTime", "The Late Guy"))
+ }
}
private fun addPlayers(nbPlayers: Int) {
@@ -124,9 +125,11 @@ class LobbyTest {
}
}
- @Test(expected = UnknownPlayerException::class)
+ @Test
fun removePlayer_failsWhenNotPresent() {
- lobby.removePlayer("anyname")
+ assertFailsWith<UnknownPlayerException> {
+ lobby.removePlayer("anyname")
+ }
}
@Test
@@ -157,40 +160,52 @@ class LobbyTest {
assertEquals(reorderedUsernames, lobby.getPlayers().map { it.username })
}
- @Test(expected = PlayerListMismatchException::class)
+ @Test
fun reorderPlayers_failsOnUnknownPlayer() {
val player1 = Player("testuser1", "Test User 1")
val player2 = Player("testuser2", "Test User 2")
lobby.addPlayer(player1)
lobby.addPlayer(player2)
- lobby.reorderPlayers(listOf("unknown", "testuser2", "gameowner"))
+
+ assertFailsWith<PlayerListMismatchException> {
+ lobby.reorderPlayers(listOf("unknown", "testuser2", "gameowner"))
+ }
}
- @Test(expected = PlayerListMismatchException::class)
+ @Test
fun reorderPlayers_failsOnExtraPlayer() {
val player1 = Player("testuser1", "Test User 1")
val player2 = Player("testuser2", "Test User 2")
lobby.addPlayer(player1)
lobby.addPlayer(player2)
- lobby.reorderPlayers(listOf("testuser2", "onemore", "testuser1", "gameowner"))
+
+ assertFailsWith<PlayerListMismatchException> {
+ lobby.reorderPlayers(listOf("testuser2", "onemore", "testuser1", "gameowner"))
+ }
}
- @Test(expected = PlayerListMismatchException::class)
+ @Test
fun reorderPlayers_failsOnMissingPlayer() {
val player1 = Player("testuser1", "Test User 1")
val player2 = Player("testuser2", "Test User 2")
lobby.addPlayer(player1)
lobby.addPlayer(player2)
- lobby.reorderPlayers(listOf("testuser2", "gameowner"))
+
+ assertFailsWith<PlayerListMismatchException> {
+ lobby.reorderPlayers(listOf("testuser2", "gameowner"))
+ }
}
@Theory
fun startGame_failsBelowMinPlayers(nbPlayers: Int) {
assumeTrue(nbPlayers < gameDefinition.minPlayers)
- thrown.expect(PlayerUnderflowException::class.java)
+
// there is already the owner
addPlayers(nbPlayers - 1)
- lobby.startGame()
+
+ assertFailsWith<PlayerUnderflowException> {
+ lobby.startGame()
+ }
}
@Theory
diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/repositories/LobbyRepositoryTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/repositories/LobbyRepositoryTest.kt
index 84f7eacf..446feee6 100644
--- a/backend/src/test/kotlin/org/luxons/sevenwonders/repositories/LobbyRepositoryTest.kt
+++ b/backend/src/test/kotlin/org/luxons/sevenwonders/repositories/LobbyRepositoryTest.kt
@@ -3,6 +3,7 @@ package org.luxons.sevenwonders.repositories
import org.junit.Before
import org.junit.Test
import org.luxons.sevenwonders.lobby.Player
+import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
import kotlin.test.assertSame
import kotlin.test.assertTrue
@@ -38,9 +39,11 @@ class LobbyRepositoryTest {
assertTrue(lobby.isOwner(owner.username))
}
- @Test(expected = LobbyNotFoundException::class)
+ @Test
fun find_failsOnUnknownId() {
- repository.find(123)
+ assertFailsWith<LobbyNotFoundException> {
+ repository.find(123)
+ }
}
@Test
@@ -52,9 +55,11 @@ class LobbyRepositoryTest {
assertSame(lobby2, repository.find(lobby2.id))
}
- @Test(expected = LobbyNotFoundException::class)
+ @Test
fun remove_failsOnUnknownId() {
- repository.remove(123)
+ assertFailsWith<LobbyNotFoundException> {
+ repository.remove(123)
+ }
}
@Test
diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/repositories/PlayerRepositoryTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/repositories/PlayerRepositoryTest.kt
index e364275d..aeedc54c 100644
--- a/backend/src/test/kotlin/org/luxons/sevenwonders/repositories/PlayerRepositoryTest.kt
+++ b/backend/src/test/kotlin/org/luxons/sevenwonders/repositories/PlayerRepositoryTest.kt
@@ -3,6 +3,7 @@ package org.luxons.sevenwonders.repositories
import org.junit.Before
import org.junit.Test
import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertSame
import kotlin.test.assertTrue
@@ -42,9 +43,11 @@ class PlayerRepositoryTest {
assertEquals("Much Better Name", player1Updated.displayName)
}
- @Test(expected = PlayerNotFoundException::class)
+ @Test
fun find_failsOnUnknownUsername() {
- repository.find("anyUsername")
+ assertFailsWith<PlayerNotFoundException> {
+ repository.find("anyUsername")
+ }
}
@Test
@@ -55,9 +58,11 @@ class PlayerRepositoryTest {
assertSame(player2, repository.find("player2"))
}
- @Test(expected = PlayerNotFoundException::class)
+ @Test
fun remove_failsOnUnknownUsername() {
- repository.remove("anyUsername")
+ assertFailsWith<PlayerNotFoundException> {
+ repository.remove("anyUsername")
+ }
}
@Test
diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/validation/DestinationAccessValidatorTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/validation/DestinationAccessValidatorTest.kt
index 88853b6c..85d03e99 100644
--- a/backend/src/test/kotlin/org/luxons/sevenwonders/validation/DestinationAccessValidatorTest.kt
+++ b/backend/src/test/kotlin/org/luxons/sevenwonders/validation/DestinationAccessValidatorTest.kt
@@ -6,6 +6,7 @@ import org.luxons.sevenwonders.lobby.Lobby
import org.luxons.sevenwonders.lobby.Player
import org.luxons.sevenwonders.repositories.LobbyNotFoundException
import org.luxons.sevenwonders.repositories.LobbyRepository
+import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertTrue
@@ -68,28 +69,36 @@ class DestinationAccessValidatorTest {
assertTrue(destinationAccessValidator.hasAccess("testUser", "/lobby/notANumber/suffix"))
}
- @Test(expected = LobbyNotFoundException::class)
+ @Test
fun validate_failWhenNoLobbyExist() {
- destinationAccessValidator.hasAccess("", "/lobby/0")
+ assertFailsWith<LobbyNotFoundException> {
+ destinationAccessValidator.hasAccess("", "/lobby/0")
+ }
}
- @Test(expected = LobbyNotFoundException::class)
+ @Test
fun validate_failWhenNoGameExist() {
- destinationAccessValidator.hasAccess("", "/game/0")
+ assertFailsWith<LobbyNotFoundException> {
+ destinationAccessValidator.hasAccess("", "/game/0")
+ }
}
- @Test(expected = LobbyNotFoundException::class)
+ @Test
fun validate_failWhenReferencedLobbyDoesNotExist() {
createLobby("Test Game", "ownerUser1")
createLobby("Test Game 2", "ownerUser2")
- destinationAccessValidator.hasAccess("doesNotMatter", "/lobby/3")
+ assertFailsWith<LobbyNotFoundException> {
+ destinationAccessValidator.hasAccess("doesNotMatter", "/lobby/3")
+ }
}
- @Test(expected = LobbyNotFoundException::class)
+ @Test
fun validate_failWhenReferencedGameDoesNotExist() {
createGame("Test Game 1", "user1", "user2", "user3")
createGame("Test Game 2", "user4", "user5", "user6")
- destinationAccessValidator.hasAccess("doesNotMatter", "/game/3")
+ assertFailsWith<LobbyNotFoundException> {
+ destinationAccessValidator.hasAccess("doesNotMatter", "/game/3")
+ }
}
@Test
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 d8a10777..d1b7c239 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
@@ -2,13 +2,11 @@ package org.luxons.sevenwonders.game.boards
import junit.framework.TestCase.assertEquals
import org.junit.Assume.assumeTrue
-import org.junit.Rule
import org.junit.Test
import org.junit.experimental.theories.DataPoints
import org.junit.experimental.theories.FromDataPoints
import org.junit.experimental.theories.Theories
import org.junit.experimental.theories.Theory
-import org.junit.rules.ExpectedException
import org.junit.runner.RunWith
import org.luxons.sevenwonders.game.boards.Board.InsufficientFundsException
import org.luxons.sevenwonders.game.cards.Color
@@ -26,6 +24,7 @@ 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.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertSame
import kotlin.test.assertTrue
@@ -33,10 +32,6 @@ import kotlin.test.assertTrue
@RunWith(Theories::class)
class BoardTest {
- @JvmField
- @Rule
- var thrown: ExpectedException = ExpectedException.none()
-
@Theory
fun initialGold_respectsSettings(@FromDataPoints("gold") goldAmountInSettings: Int) {
val settings = testSettings(initialGold = goldAmountInSettings)
@@ -72,10 +67,11 @@ class BoardTest {
) {
assumeTrue(goldRemoved >= 0)
assumeTrue(initialGold < goldRemoved)
- thrown.expect(InsufficientFundsException::class.java)
- val board = Board(testWonder(), 0, testSettings(initialGold = initialGold))
- board.removeGold(goldRemoved)
+ assertFailsWith<InsufficientFundsException> {
+ val board = Board(testWonder(), 0, testSettings(initialGold = initialGold))
+ board.removeGold(goldRemoved)
+ }
}
@Theory
@@ -121,8 +117,9 @@ class BoardTest {
val board = testBoard()
val card = testCard(color = color)
- thrown.expect(IllegalArgumentException::class.java)
- board.copiedGuild = card
+ assertFailsWith<IllegalArgumentException> {
+ board.copiedGuild = card
+ }
}
@Theory
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 dd2696f4..248d43dd 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,22 +1,17 @@
package org.luxons.sevenwonders.game.boards
-import org.junit.Rule
import org.junit.experimental.theories.DataPoints
import org.junit.experimental.theories.FromDataPoints
import org.junit.experimental.theories.Theories
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 kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
@RunWith(Theories::class)
class MilitaryTest {
- @JvmField
- @Rule
- var thrown = ExpectedException.none()
-
@Theory
fun victory_addsCorrectPoints(
@FromDataPoints("ages") age: Int,
@@ -32,8 +27,9 @@ class MilitaryTest {
@Theory
fun victory_failsIfUnknownAge(@FromDataPoints("points") nbPointsPerVictory: Int) {
val military = createMilitary(0, nbPointsPerVictory, 0)
- thrown.expect(UnknownAgeException::class.java)
- military.victory(1)
+ assertFailsWith<UnknownAgeException> {
+ military.victory(1)
+ }
}
@Theory
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 d42fca63..f6c45720 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,42 +1,43 @@
package org.luxons.sevenwonders.game.cards
import org.junit.Assume.assumeTrue
-import org.junit.Rule
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.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.assertFailsWith
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
@RunWith(Theories::class)
class DecksTest {
- @JvmField
- @Rule
- val thrown: ExpectedException = ExpectedException.none()
-
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun getCard_failsOnEmptyNameWhenDeckIsEmpty() {
val decks = createDecks(0, 0)
- decks.getCard(0, "")
+ assertFailsWith<IllegalArgumentException> {
+ decks.getCard(0, "")
+ }
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun getCard_failsWhenDeckIsEmpty() {
val decks = createDecks(0, 0)
- decks.getCard(0, "Any name")
+ assertFailsWith<IllegalArgumentException> {
+ decks.getCard(0, "Any name")
+ }
}
- @Test(expected = CardNotFoundException::class)
+ @Test
fun getCard_failsWhenCardIsNotFound() {
val decks = createDecks(3, 20)
- decks.getCard(1, "Unknown name")
+ assertFailsWith<CardNotFoundException> {
+ decks.getCard(1, "Unknown name")
+ }
}
@Test
@@ -46,24 +47,29 @@ class DecksTest {
assertEquals("Test Card 3", name)
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deal_failsOnZeroPlayers() {
val decks = createDecks(3, 20)
- decks.deal(1, 0)
+ assertFailsWith<IllegalArgumentException> {
+ decks.deal(1, 0)
+ }
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deal_failsOnMissingAge() {
val decks = createDecks(2, 0)
- decks.deal(4, 10)
+ assertFailsWith<IllegalArgumentException> {
+ decks.deal(4, 10)
+ }
}
@Theory
fun deal_failsWhenTooFewPlayers(nbPlayers: Int, nbCards: Int) {
assumeTrue(nbCards % nbPlayers != 0)
- thrown.expect(IllegalArgumentException::class.java)
val decks = createDecks(1, nbCards)
- decks.deal(1, nbPlayers)
+ assertFailsWith<IllegalArgumentException> {
+ decks.deal(1, nbPlayers)
+ }
}
@Theory
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 5a71aeda..c7ff9106 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
@@ -11,16 +11,18 @@ 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.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertTrue
@RunWith(Theories::class)
class HandsTest {
- @Test(expected = IndexOutOfBoundsException::class)
+ @Test
fun get_failsOnMissingPlayer() {
val hands = createHands(4, 7)
- hands[5]
+
+ assertFailsWith<IndexOutOfBoundsException> { hands[5] }
}
@Test
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 dbd5a9a2..9b44fad2 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
@@ -15,6 +15,7 @@ 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
+import kotlin.test.assertFailsWith
@RunWith(Theories::class)
class NumericEffectSerializerTest {
@@ -27,8 +28,7 @@ class NumericEffectSerializerTest {
.registerTypeAdapter(RawPointsIncrease::class.java, NumericEffectSerializer())
.registerTypeAdapter(GoldIncrease::class.java, NumericEffectSerializer())
// ProductionIncrease is not a numeric effect, it is here for negative testing purpose
- .registerTypeAdapter(ProductionIncrease::class.java, NumericEffectSerializer())
- .create()
+ .registerTypeAdapter(ProductionIncrease::class.java, NumericEffectSerializer()).create()
}
@Test
@@ -46,9 +46,11 @@ class NumericEffectSerializerTest {
assertEquals("null", gson.toJson(null, GoldIncrease::class.java))
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun serialize_failOnUnknownType() {
- gson.toJson(ProductionIncrease(Production(), false))
+ assertFailsWith<IllegalArgumentException> {
+ gson.toJson(ProductionIncrease(Production(), false))
+ }
}
@Theory
@@ -87,39 +89,53 @@ class NumericEffectSerializerTest {
assertEquals(goldIncrease, gson.fromJson<GoldIncrease>(count.toString()))
}
- @Test(expected = NumberFormatException::class)
+ @Test
fun deserialize_militaryReinforcements_failOnEmptyString() {
- gson.fromJson<MilitaryReinforcements>("\"\"")
+ assertFailsWith<NumberFormatException> {
+ gson.fromJson<MilitaryReinforcements>("\"\"")
+ }
}
- @Test(expected = NumberFormatException::class)
+ @Test
fun deserialize_rawPointsIncrease_failOnEmptyString() {
- gson.fromJson<RawPointsIncrease>("\"\"")
+ assertFailsWith<NumberFormatException> {
+ gson.fromJson<RawPointsIncrease>("\"\"")
+ }
}
- @Test(expected = NumberFormatException::class)
+ @Test
fun deserialize_goldIncrease_failOnEmptyString() {
- gson.fromJson<GoldIncrease>("\"\"")
+ assertFailsWith<NumberFormatException> {
+ gson.fromJson<GoldIncrease>("\"\"")
+ }
}
- @Test(expected = NumberFormatException::class)
+ @Test
fun deserialize_militaryReinforcements_failOnNonNumericString() {
- gson.fromJson<MilitaryReinforcements>("\"abc\"")
+ assertFailsWith<NumberFormatException> {
+ gson.fromJson<MilitaryReinforcements>("\"abc\"")
+ }
}
- @Test(expected = NumberFormatException::class)
+ @Test
fun deserialize_rawPointsIncrease_failOnNonNumericString() {
- gson.fromJson<RawPointsIncrease>("\"abc\"")
+ assertFailsWith<NumberFormatException> {
+ gson.fromJson<RawPointsIncrease>("\"abc\"")
+ }
}
- @Test(expected = NumberFormatException::class)
+ @Test
fun deserialize_goldIncrease_failOnNonNumericString() {
- gson.fromJson<GoldIncrease>("\"abc\"")
+ assertFailsWith<NumberFormatException> {
+ gson.fromJson<GoldIncrease>("\"abc\"")
+ }
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deserialize_failOnUnknownType() {
- gson.fromJson<ProductionIncrease>("\"2\"")
+ assertFailsWith<IllegalArgumentException> {
+ 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 8354ab21..31d695e8 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
@@ -110,18 +110,22 @@ class ProductionIncreaseSerializerTest {
assertEquals("\"W/O/C\"", gson.toJson(prodIncrease))
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun serialize_failIfMultipleChoices() {
val prodIncrease = createChoice(true, ResourceType.WOOD, ResourceType.CLAY)
prodIncrease.production.addChoice(ResourceType.ORE, ResourceType.GLASS)
- gson.toJson(prodIncrease)
+ assertFailsWith<IllegalArgumentException> {
+ gson.toJson(prodIncrease)
+ }
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun serialize_failIfMixedFixedAndChoices() {
val prodIncrease = create(true, 1, 0, 0)
prodIncrease.production.addChoice(ResourceType.WOOD, ResourceType.CLAY)
- gson.toJson(prodIncrease)
+ assertFailsWith<IllegalArgumentException> {
+ gson.toJson(prodIncrease)
+ }
}
@Test
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 82d99fb8..265087ba 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
@@ -11,6 +11,7 @@ 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 ProductionSerializerTest {
@@ -24,8 +25,7 @@ class ProductionSerializerTest {
.registerTypeAdapter(MutableResources::class.java, ResourcesSerializer())
.registerTypeAdapter(ResourceType::class.java, ResourceTypeSerializer())
.registerTypeAdapter(resourceTypeList, ResourceTypesSerializer())
- .registerTypeAdapter(Production::class.java, ProductionSerializer())
- .create()
+ .registerTypeAdapter(Production::class.java, ProductionSerializer()).create()
}
private fun create(wood: Int, stone: Int, clay: Int): Production {
@@ -107,18 +107,22 @@ class ProductionSerializerTest {
assertEquals("\"W/O/C\"", gson.toJson(prodIncrease))
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun serialize_failIfMultipleChoices() {
val production = createChoice(ResourceType.WOOD, ResourceType.CLAY)
production.addChoice(ResourceType.ORE, ResourceType.GLASS)
- gson.toJson(production)
+ assertFailsWith<IllegalArgumentException> {
+ gson.toJson(production)
+ }
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun serialize_failIfMixedFixedAndChoices() {
val production = create(1, 0, 0)
production.addChoice(ResourceType.WOOD, ResourceType.CLAY)
- gson.toJson(production)
+ assertFailsWith<IllegalArgumentException> {
+ gson.toJson(production)
+ }
}
@Test
@@ -132,14 +136,18 @@ class ProductionSerializerTest {
assertEquals(prodIncrease, gson.fromJson("\"\""))
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deserialize_failOnGarbageString() {
- gson.fromJson<Production>("\"this is garbage\"")
+ assertFailsWith<IllegalArgumentException> {
+ gson.fromJson<Production>("\"this is garbage\"")
+ }
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deserialize_failOnGarbageStringWithSlashes() {
- gson.fromJson<Production>("\"this/is/garbage\"")
+ assertFailsWith<IllegalArgumentException> {
+ gson.fromJson<Production>("\"this/is/garbage\"")
+ }
}
@Test
@@ -190,8 +198,10 @@ class ProductionSerializerTest {
assertEquals(prodIncrease, gson.fromJson("\"W/O/C\""))
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deserialize_failOnMultipleResourcesInChoice() {
- gson.fromJson<Production>("\"W/SS/C\"")
+ assertFailsWith<IllegalArgumentException> {
+ 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 eee04047..f2b07e84 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
@@ -7,6 +7,7 @@ import org.junit.Before
import org.junit.Test
import org.luxons.sevenwonders.game.resources.ResourceType
import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
import kotlin.test.assertNull
class ResourceTypeSerializerTest {
@@ -39,13 +40,17 @@ class ResourceTypeSerializerTest {
assertNull(gson.fromJson("null", ResourceType::class.java))
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deserialize_failsOnEmptyString() {
- gson.fromJson<ResourceType>("\"\"")
+ assertFailsWith<IllegalArgumentException> {
+ gson.fromJson<ResourceType>("\"\"")
+ }
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deserialize_failsOnGarbageString() {
- gson.fromJson<ResourceType>("\"thisisgarbage\"")
+ assertFailsWith<IllegalArgumentException> {
+ gson.fromJson<ResourceType>("\"thisisgarbage\"")
+ }
}
}
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 1c95bb36..95d72517 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
@@ -9,6 +9,7 @@ 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.assertFailsWith
import kotlin.test.assertNotNull
private const val TABLET_STR = "\"TABLET\""
@@ -60,44 +61,58 @@ class ScienceProgressSerializerTest {
assertEquals(JOKER_STR, json)
}
- @Test(expected = UnsupportedOperationException::class)
+ @Test
fun serialize_failOnMultipleCompasses() {
- val progress = createScienceProgress(2, 0, 0, 0)
- gson.toJson(progress)
+ assertFailsWith<UnsupportedOperationException> {
+ val progress = createScienceProgress(2, 0, 0, 0)
+ gson.toJson(progress)
+ }
}
- @Test(expected = UnsupportedOperationException::class)
+ @Test
fun serialize_failOnMultipleWheels() {
- val progress = createScienceProgress(0, 2, 0, 0)
- gson.toJson(progress)
+ assertFailsWith<UnsupportedOperationException> {
+ val progress = createScienceProgress(0, 2, 0, 0)
+ gson.toJson(progress)
+ }
}
- @Test(expected = UnsupportedOperationException::class)
+ @Test
fun serialize_failOnMultipleTablets() {
- val progress = createScienceProgress(0, 0, 2, 0)
- gson.toJson(progress)
+ assertFailsWith<UnsupportedOperationException> {
+ val progress = createScienceProgress(0, 0, 2, 0)
+ gson.toJson(progress)
+ }
}
- @Test(expected = UnsupportedOperationException::class)
+ @Test
fun serialize_failOnMultipleJokers() {
- val progress = createScienceProgress(0, 0, 0, 2)
- gson.toJson(progress)
+ assertFailsWith<UnsupportedOperationException> {
+ val progress = createScienceProgress(0, 0, 0, 2)
+ gson.toJson(progress)
+ }
}
- @Test(expected = UnsupportedOperationException::class)
+ @Test
fun serialize_failOnMixedElements() {
- val progress = createScienceProgress(1, 1, 0, 0)
- gson.toJson(progress)
+ assertFailsWith<UnsupportedOperationException> {
+ val progress = createScienceProgress(1, 1, 0, 0)
+ gson.toJson(progress)
+ }
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deserialize_failOnEmptyString() {
- gson.fromJson<ScienceProgress>("\"\"")
+ assertFailsWith<IllegalArgumentException> {
+ gson.fromJson<ScienceProgress>("\"\"")
+ }
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun deserialize_failOnGarbageString() {
- gson.fromJson<ScienceProgress>("thisisgarbage")
+ assertFailsWith<IllegalArgumentException> {
+ gson.fromJson<ScienceProgress>("thisisgarbage")
+ }
}
@Test
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 524124b4..aae3be8e 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
@@ -13,6 +13,7 @@ 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.assertFailsWith
import kotlin.test.assertTrue
@RunWith(Theories::class)
@@ -52,11 +53,13 @@ class SpecialAbilityActivationTest {
assertEquals(directPointsFromGuildCard, effect.computePoints(player))
}
- @Test(expected = IllegalStateException::class)
+ @Test
fun computePoints_copyGuild_failWhenNoChosenGuild() {
val effect = SpecialAbilityActivation(SpecialAbility.COPY_GUILD)
val player = SimplePlayer(0, testTable(5))
- effect.computePoints(player)
+ assertFailsWith<IllegalStateException> {
+ effect.computePoints(player)
+ }
}
companion object {
@@ -67,7 +70,8 @@ class SpecialAbilityActivationTest {
@JvmStatic
@DataPoints
- fun neighbours(): Array<RelativeBoardPosition> = arrayOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT)
+ fun neighbours(): Array<RelativeBoardPosition> =
+ arrayOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT)
@JvmStatic
@DataPoints
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 b0667d67..21b92872 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
@@ -11,20 +11,24 @@ 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.assertFailsWith
import kotlin.test.fail
class BuildWonderMoveTest {
- @Test(expected = InvalidMoveException::class)
+ @Test
fun init_failsWhenCardNotInHand() {
val table = testTable(3)
val hand = sampleCards(7)
val playerContext = PlayerContext(0, table, hand)
val anotherCard = testCard("Card that is not in the hand")
- createMove(playerContext, anotherCard, MoveType.UPGRADE_WONDER)
+
+ assertFailsWith<InvalidMoveException> {
+ createMove(playerContext, anotherCard, MoveType.UPGRADE_WONDER)
+ }
}
- @Test(expected = InvalidMoveException::class)
+ @Test
fun init_failsWhenWonderIsCompletelyBuilt() {
val settings = testSettings(3)
val table = testTable(settings)
@@ -33,7 +37,9 @@ class BuildWonderMoveTest {
fillPlayerWonderLevels(settings, table, hand)
// should fail because the wonder is already full
- buildOneWonderLevel(settings, table, hand, 4)
+ assertFailsWith<InvalidMoveException> {
+ buildOneWonderLevel(settings, table, hand, 4)
+ }
}
private fun fillPlayerWonderLevels(settings: Settings, table: Table, hand: List<Card>) {
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 ba20bc62..634a25c7 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,6 @@
package org.luxons.sevenwonders.game.resources
-import org.junit.Rule
import org.junit.Test
-import org.junit.rules.ExpectedException
import org.luxons.sevenwonders.game.resources.ResourceType.CLAY
import org.luxons.sevenwonders.game.resources.ResourceType.GLASS
import org.luxons.sevenwonders.game.resources.ResourceType.LOOM
@@ -12,15 +10,12 @@ 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.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertTrue
class ResourcesTest {
- @JvmField
- @Rule
- var thrown = ExpectedException.none()
-
@Test
fun init_shouldBeEmpty() {
val resources = emptyResources()
@@ -143,8 +138,9 @@ class ResourcesTest {
fun remove_tooMany() {
val resources = mutableResourcesOf(WOOD to 2)
- thrown.expect(NoSuchElementException::class.java)
- resources.remove(WOOD, 3)
+ assertFailsWith<NoSuchElementException> {
+ resources.remove(WOOD, 3)
+ }
}
@Test
bgstack15