Add tests for most command plugins

This commit is contained in:
Gary Tierney
2018-09-04 00:02:00 +01:00
parent 9a8f94df18
commit 2ea0f68eb9
7 changed files with 258 additions and 4 deletions
+42
View File
@@ -0,0 +1,42 @@
import org.apollo.cache.def.ItemDefinition
import org.apollo.game.command.Command
import org.apollo.game.model.World
import org.apollo.game.model.entity.Player
import org.apollo.game.model.entity.setting.PrivilegeLevel
import org.apollo.game.plugin.testing.junit.ApolloTestingExtension
import org.apollo.game.plugin.testing.junit.api.annotations.ItemDefinitions
import org.apollo.game.plugin.testing.junit.api.annotations.TestMock
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@ExtendWith(ApolloTestingExtension::class)
class ItemCommandTests {
@TestMock
lateinit var world: World
@TestMock
lateinit var player: Player
@Test
fun `Defaults to an amount of 1`() {
player.privilegeLevel = PrivilegeLevel.ADMINISTRATOR
world.commandDispatcher.dispatch(player, Command("item", arrayOf("1")))
assertEquals(1, player.inventory.getAmount(1))
}
@Test
fun `Adds item of specified amount to inventory`() {
player.privilegeLevel = PrivilegeLevel.ADMINISTRATOR
world.commandDispatcher.dispatch(player, Command("item", arrayOf("1", "10")))
assertEquals(10, player.inventory.getAmount(1))
}
companion object {
@ItemDefinitions
val items = listOf(ItemDefinition(1))
}
}