mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Remove test context from plugin testing framework
This commit is contained in:
@@ -14,25 +14,23 @@ class OpenBankTest() : KotlinPluginTest() {
|
||||
|
||||
@Test
|
||||
fun `Interacting with a bank teller should open the players bank`() {
|
||||
val ctx = context()
|
||||
val bankTeller = ctx.spawnNpc(BANK_TELLER_ID, BANK_POSITION)
|
||||
val bankTeller = spawnNpc(BANK_TELLER_ID, BANK_POSITION)
|
||||
|
||||
// @todo - these option numbers only match by coincidence, we should be looking up the correct ones
|
||||
ctx.interactWith(bankTeller, option = 2)
|
||||
ctx.waitForActionCompletion()
|
||||
interactWith(bankTeller, option = 2)
|
||||
waitForActionCompletion()
|
||||
|
||||
verify(ctx.activePlayer).openBank()
|
||||
verify(player).openBank()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Interacting with a bank booth object should open the players bank`() {
|
||||
val ctx = context()
|
||||
val bankBooth = ctx.spawnObject(BANK_BOOTH_ID, BANK_POSITION)
|
||||
val bankBooth = spawnObject(BANK_BOOTH_ID, BANK_POSITION)
|
||||
|
||||
ctx.interactWith(bankBooth, option = 2)
|
||||
ctx.waitForActionCompletion()
|
||||
interactWith(bankBooth, option = 2)
|
||||
waitForActionCompletion()
|
||||
|
||||
verify(ctx.activePlayer).openBank()
|
||||
verify(player).openBank()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.entity.Skill
|
||||
import org.apollo.game.model.entity.SkillSet
|
||||
import org.apollo.game.plugins.testing.KotlinPluginTest
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.hamcrest.Matchers.*
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.mockito.Matchers
|
||||
import org.mockito.Matchers.*
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.*
|
||||
|
||||
class TrainingDummyTest : KotlinPluginTest() {
|
||||
|
||||
@@ -16,30 +14,30 @@ class TrainingDummyTest : KotlinPluginTest() {
|
||||
}
|
||||
|
||||
@Test fun `Hitting the training dummy should give the player attack experience`() {
|
||||
val ctx = context()
|
||||
val dummy = ctx.spawnObject(DUMMY_ID, DUMMY_POSITION)
|
||||
val skills = ctx.activePlayer.skillSet
|
||||
val attackExp = skills.getExperience(Skill.ATTACK)
|
||||
val dummy = spawnObject(DUMMY_ID, DUMMY_POSITION)
|
||||
val skills = player.skillSet
|
||||
val beforeExp = skills.getExperience(Skill.ATTACK)
|
||||
|
||||
ctx.interactWith(dummy, option = 2)
|
||||
ctx.waitForActionCompletion()
|
||||
interactWith(dummy, option = 2)
|
||||
waitForActionCompletion()
|
||||
|
||||
assertTrue("Did not gain exp after hitting dummy", skills.getExperience(Skill.ATTACK) > attackExp)
|
||||
val afterExp = skills.getExperience(Skill.ATTACK)
|
||||
assertThat(afterExp, greaterThan(beforeExp))
|
||||
}
|
||||
|
||||
@Test fun `The player should stop getting attack experience from the training dummy at level 8`() {
|
||||
val ctx = context()
|
||||
|
||||
val dummy = ctx.spawnObject(DUMMY_ID, DUMMY_POSITION)
|
||||
val skills = ctx.activePlayer.skillSet
|
||||
val dummy = spawnObject(DUMMY_ID, DUMMY_POSITION)
|
||||
val skills = player.skillSet
|
||||
skills.setMaximumLevel(Skill.ATTACK, 8)
|
||||
val attackExp = skills.getExperience(Skill.ATTACK)
|
||||
val beforeExp = skills.getExperience(Skill.ATTACK)
|
||||
|
||||
ctx.interactWith(dummy, option = 2)
|
||||
ctx.waitForActionCompletion()
|
||||
interactWith(dummy, option = 2)
|
||||
waitForActionCompletion()
|
||||
|
||||
verify(ctx.activePlayer).sendMessage(contains("nothing more you can learn"))
|
||||
assertTrue("Attack exp has changed since hitting the dummy", attackExp == skills.getExperience(Skill.ATTACK))
|
||||
val afterExp = skills.getExperience(Skill.ATTACK)
|
||||
|
||||
verify(player).sendMessage(contains("nothing more you can learn"))
|
||||
assertThat(afterExp, equalTo(beforeExp))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user