mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Update plugin test framework to junit5
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.
This commit is contained in:
@@ -29,30 +29,28 @@ val Player.runecraft: SkillProxy get() = SkillProxy(skillSet, Skill.RUNECRAFT)
|
||||
/**
|
||||
* A proxy class to allow
|
||||
*/
|
||||
class SkillProxy(val skills: SkillSet, val skill: Int) {
|
||||
class SkillProxy(private val skills: SkillSet, private val skill: Int) {
|
||||
|
||||
/**
|
||||
* The maximum level of this skill.
|
||||
*/
|
||||
val maximum = skills.getMaximumLevel(skill)
|
||||
val maximum: Int
|
||||
get() = skills.getMaximumLevel(skill)
|
||||
|
||||
/**
|
||||
* The current level of this skill.
|
||||
*/
|
||||
val current = skills.getCurrentLevel(skill)
|
||||
|
||||
val experience = ExperienceProxy()
|
||||
val current: Int
|
||||
get() = skills.getCurrentLevel(skill)
|
||||
|
||||
/**
|
||||
* A proxy class to make [experience] (effectively) write-only.
|
||||
* The amount of experience in this skill a player has.
|
||||
*/
|
||||
inner class ExperienceProxy {
|
||||
|
||||
operator fun plusAssign(amount: Int) = skills.addExperience(skill, amount.toDouble())
|
||||
|
||||
operator fun plusAssign(amount: Double) = skills.addExperience(skill, amount)
|
||||
|
||||
}
|
||||
var experience: Double
|
||||
get() = skills.getExperience(skill)
|
||||
set(value) {
|
||||
skills.setExperience(skill, value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Boosts the current level of this skill by [amount], if possible (i.e. if `current + amount <= maximum + amount`).
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.apollo.game.plugin.api
|
||||
|
||||
import java.util.Random
|
||||
import java.util.*
|
||||
|
||||
val RAND = Random()
|
||||
public val RAND = Random()
|
||||
|
||||
fun rand(bounds: Int): Int {
|
||||
return RAND.nextInt(bounds)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import org.apollo.cache.def.ItemDefinition
|
||||
import org.apollo.game.plugin.api.Definitions
|
||||
import org.apollo.game.plugin.testing.KotlinPluginTest
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Test
|
||||
|
||||
class NamedLookupTests : KotlinPluginTest() {
|
||||
@Test
|
||||
fun itemLookup() {
|
||||
val testItem = ItemDefinition(0)
|
||||
testItem.name = "sword"
|
||||
|
||||
ItemDefinition.init(arrayOf(testItem))
|
||||
|
||||
assertThat(Definitions.item("sword")).isEqualTo(testItem)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user