Allow multiple players per test

Refactors the test helpers to use receiver functions so multiple players
can exist in the world per test case.  The AddFriendsTest is an example
of where this is needed.

Additionally, Hamcrest has been replaced with AssertJ for fluent
assertions.
This commit is contained in:
Gary Tierney
2017-06-20 02:13:47 +01:00
parent b532168551
commit 182de0330f
15 changed files with 254 additions and 186 deletions
@@ -1,10 +1,10 @@
import org.apollo.game.model.Position
import org.apollo.game.model.entity.Skill
import org.apollo.game.plugins.testing.KotlinPluginTest
import org.hamcrest.Matchers.*
import org.junit.Assert.*
import org.apollo.game.plugin.testing.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.mockito.Mockito.*
import org.mockito.Mockito.contains
import org.mockito.Mockito.verify
class TrainingDummyTest : KotlinPluginTest() {
@@ -14,30 +14,30 @@ class TrainingDummyTest : KotlinPluginTest() {
}
@Test fun `Hitting the training dummy should give the player attack experience`() {
val dummy = spawnObject(DUMMY_ID, DUMMY_POSITION)
val dummy = world.spawnObject(DUMMY_ID, DUMMY_POSITION)
val skills = player.skillSet
val beforeExp = skills.getExperience(Skill.ATTACK)
interactWith(dummy, option = 2)
waitForActionCompletion()
player.interactWith(dummy, option = 2)
player.waitForActionCompletion()
val afterExp = skills.getExperience(Skill.ATTACK)
assertThat(afterExp, greaterThan(beforeExp))
assertThat(afterExp).isGreaterThan(beforeExp)
}
@Test fun `The player should stop getting attack experience from the training dummy at level 8`() {
val dummy = spawnObject(DUMMY_ID, DUMMY_POSITION)
val dummy = world.spawnObject(DUMMY_ID, DUMMY_POSITION)
val skills = player.skillSet
skills.setMaximumLevel(Skill.ATTACK, 8)
val beforeExp = skills.getExperience(Skill.ATTACK)
interactWith(dummy, option = 2)
waitForActionCompletion()
player.interactWith(dummy, option = 2)
player.waitForActionCompletion()
val afterExp = skills.getExperience(Skill.ATTACK)
verify(player).sendMessage(contains("nothing more you can learn"))
assertThat(afterExp, equalTo(beforeExp))
assertThat(afterExp).isEqualTo(beforeExp)
}
}
}