-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests and fix broken placeholder hands
- Loading branch information
1 parent
9a3926f
commit 08b8d56
Showing
8 changed files
with
167 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package room | ||
|
||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.shouldNotBe | ||
import org.junit.jupiter.api.Assertions.* | ||
import org.junit.jupiter.api.Test | ||
import testCore.AbstractTest | ||
import util.makeGameSettings | ||
import util.makeRoom | ||
|
||
class RoomTest : AbstractTest() { | ||
@Test | ||
fun `should report correct name`() { | ||
makeRoom(baseName = "Mercury", index = 1).name shouldBe "Mercury 1" | ||
makeRoom(baseName = "Carbon", index = 5).name shouldBe "Carbon 5" | ||
} | ||
|
||
@Test | ||
fun `should report if room is a copy`() { | ||
makeRoom(baseName = "Mercury", index = 1).isCopy shouldBe false | ||
makeRoom(baseName = "Carbon", index = 2).isCopy shouldBe true | ||
makeRoom(baseName = "Oxygen", index = 5).isCopy shouldBe true | ||
} | ||
|
||
@Test | ||
fun `should make a copy of a room`() { | ||
val settings = makeGameSettings(includeMoons = true, jokerQuantity = 2) | ||
val room = makeRoom(baseName = "Yttrium", index = 1, settings = settings, capacity = 3) | ||
|
||
val copy = room.makeCopy() | ||
copy.id shouldNotBe room.id | ||
copy.name shouldBe "Yttrium 2" | ||
copy.settings shouldBe settings | ||
copy.capacity shouldBe room.capacity | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package store | ||
|
||
import game.GameMode | ||
import game.GameSettings | ||
import io.kotest.matchers.collections.shouldContainExactly | ||
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder | ||
import io.kotest.matchers.collections.shouldHaveSize | ||
import io.kotest.matchers.shouldBe | ||
import java.util.UUID | ||
import org.junit.jupiter.api.Test | ||
import room.Room | ||
|
||
class RoomStoreTest : AbstractStoreTest<UUID, Room>() { | ||
override fun makeStore() = RoomStore() | ||
|
||
override fun makeIdA(): UUID = UUID.fromString("e115f1ce-0021-4653-9888-ea330b07f3a8") | ||
|
||
override fun makeIdB(): UUID = UUID.fromString("7a10f6a0-03bc-4e95-a4cb-44b92582f016") | ||
|
||
override fun makeItemA(id: UUID) = Room(id, "Mercury", GameSettings(GameMode.Entropy), 2) | ||
|
||
override fun makeItemB(id: UUID) = Room(id, "Oxygen", GameSettings(GameMode.Vectropy), 3) | ||
|
||
@Test | ||
fun `Should be able to find a room for name`() { | ||
val store = makeStore() | ||
val roomA = makeItemA(UUID.randomUUID()) | ||
val roomB = makeItemB(UUID.randomUUID()) | ||
store.putAll(roomA, roomB) | ||
|
||
store.findForName("Mercury 1") shouldBe roomA | ||
store.findForName("Oxygen 1") shouldBe roomB | ||
store.findForName("Mercury 2") shouldBe null | ||
} | ||
|
||
@Test | ||
fun `Reset should remove all room copies`() { | ||
val store = makeStore() | ||
|
||
val room = makeItemA(UUID.randomUUID()) | ||
val roomCopy = room.makeCopy() | ||
val roomCopy2 = roomCopy.makeCopy() | ||
|
||
store.putAll(room, roomCopy, roomCopy2) | ||
store.reset() | ||
|
||
store.getAll().shouldContainExactly(room) | ||
} | ||
|
||
@Test | ||
fun `Should add a copy`() { | ||
val store = makeStore() | ||
|
||
val room = makeItemA(UUID.randomUUID()) | ||
store.put(room) | ||
store.addCopy(room) | ||
|
||
val rooms = store.getAll() | ||
rooms.shouldHaveSize(2) | ||
rooms.map { it.name }.shouldContainExactlyInAnyOrder("Mercury 1", "Mercury 2") | ||
} | ||
|
||
@Test | ||
fun `Should not add a copy if it would be redundant`() { | ||
val store = makeStore() | ||
|
||
val room = makeItemA(UUID.randomUUID()) | ||
store.put(room) | ||
store.addCopy(room) | ||
store.getAll().shouldHaveSize(2) | ||
|
||
store.addCopy(room) | ||
store.getAll().shouldHaveSize(2) | ||
verifyLog("roomExists") | ||
} | ||
} |
Oops, something went wrong.