Skip to content

Commit

Permalink
[#23] Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Apr 22, 2020
1 parent a3e3227 commit 6411a95
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/test/kotlin/util/ecs/storage/ComponentMapTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ private val storage = ComponentMap(TYPE, components)

class ComponentMapTest {

@Test
fun `Get correct type`() {
assertThat(storage.getType()).isSameAs(TYPE)
}

@Nested
inner class Has {
Expand Down
17 changes: 13 additions & 4 deletions src/test/kotlin/util/log/MessageLogTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,35 @@ import util.ecs.EcsState

class MessageLogTest {

private val message0 = mockk<Message>()
private val message1 = mockk<Message>()
private val message2 = mockk<Message>()

@Test
fun `Test empty constructor`() {
assertThat(MessageLog()).isEqualTo(MessageLog(emptyList()))
}

@Test
fun `Add a message to the message log`() {
val message0 = mockk<Message>()
val message1 = mockk<Message>()
val log = MessageLog(listOf(message0))

val newLog = log.add(message1)

assertThat(newLog).isEqualTo(MessageLog(listOf(message0, message1)))
}

@Test
fun `Add messages to the message log`() {
val log = MessageLog(listOf(message0))

val newLog = log.add(listOf(message1, message2))

assertThat(newLog).isEqualTo(MessageLog(listOf(message0, message1, message2)))
}

@Test
fun `Add a message to the state`() {
val message0 = mockk<Message>()
val message1 = mockk<Message>()
val log = MessageLog(listOf(message0))
val state = EcsState(dataMap = mapOf(MessageLog::class to log))

Expand Down

0 comments on commit 6411a95

Please sign in to comment.