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:
Gary Tierney
2018-08-19 22:28:41 +01:00
parent e255bd195e
commit 248a7d97d9
56 changed files with 1327 additions and 463 deletions
+11 -13
View File
@@ -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`).
+2 -2
View File
@@ -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)