mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
248a7d97d9
Updates the testing infrastructure to use the latest relesae of junit and leverages the new extension mechanism to create an easy to use testing framework. Also adds additional test coverage for several plugins.
75 lines
2.5 KiB
Kotlin
75 lines
2.5 KiB
Kotlin
import org.apollo.cache.def.ItemDefinition
|
|
import org.apollo.game.model.entity.Player
|
|
import org.apollo.game.model.entity.Skill
|
|
import org.apollo.game.plugin.skills.mining.Pickaxe
|
|
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.extension.ExtendWith
|
|
import org.junit.jupiter.params.ParameterizedTest
|
|
import org.junit.jupiter.params.provider.EnumSource
|
|
|
|
@ExtendWith(ApolloTestingExtension::class)
|
|
class PickaxeTests {
|
|
|
|
@ItemDefinitions
|
|
fun pickaxes() = Pickaxe.values().map {
|
|
ItemDefinition(it.id).apply { isStackable = false }
|
|
}
|
|
|
|
@TestMock
|
|
lateinit var player: Player
|
|
|
|
@ParameterizedTest
|
|
@EnumSource(Pickaxe::class)
|
|
fun `No pickaxe is chosen if none are available`(pickaxe: Pickaxe) {
|
|
player.skillSet.setCurrentLevel(Skill.MINING, pickaxe.level)
|
|
|
|
assertEquals(null, Pickaxe.bestFor(player))
|
|
}
|
|
|
|
|
|
@ParameterizedTest
|
|
@EnumSource(Pickaxe::class)
|
|
fun `The highest level pickaxe is chosen when available`(pickaxe: Pickaxe) {
|
|
player.skillSet.setCurrentLevel(Skill.MINING, pickaxe.level)
|
|
player.inventory.add(pickaxe.id)
|
|
|
|
assertEquals(pickaxe, Pickaxe.bestFor(player))
|
|
}
|
|
|
|
@ParameterizedTest
|
|
@EnumSource(Pickaxe::class)
|
|
fun `Only pickaxes the player has are chosen`(pickaxe: Pickaxe) {
|
|
player.skillSet.setCurrentLevel(Skill.MINING, pickaxe.level)
|
|
player.inventory.add(Pickaxe.BRONZE.id)
|
|
|
|
assertEquals(Pickaxe.BRONZE, Pickaxe.bestFor(player))
|
|
}
|
|
|
|
|
|
@ParameterizedTest
|
|
@EnumSource(value = Pickaxe::class)
|
|
fun `Pickaxes can be chosen from equipment as well as inventory`(pickaxe: Pickaxe) {
|
|
player.skillSet.setCurrentLevel(Skill.MINING, pickaxe.level)
|
|
player.inventory.add(pickaxe.id)
|
|
|
|
assertEquals(pickaxe, Pickaxe.bestFor(player))
|
|
}
|
|
|
|
|
|
@ParameterizedTest
|
|
@EnumSource(value = Pickaxe::class)
|
|
fun `Pickaxes with a level requirement higher than the player's are ignored`(pickaxe: Pickaxe) {
|
|
player.skillSet.setCurrentLevel(Skill.MINING, pickaxe.level)
|
|
player.inventory.add(pickaxe.id)
|
|
|
|
Pickaxe.values()
|
|
.filter { it.level > pickaxe.level }
|
|
.forEach { player.inventory.add(it.id) }
|
|
|
|
assertEquals(pickaxe, Pickaxe.bestFor(player))
|
|
}
|
|
|
|
} |