mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-03-12 00:40:35 +00:00
broke up GUIDTask tests into separate files; attempting to increase code coverage by modifying the first registering test
This commit is contained in:
parent
ab2e2959b5
commit
e62adc4bc1
12 changed files with 339 additions and 245 deletions
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.guidtask
|
||||
|
||||
import akka.actor.{Actor, ActorSystem, Props}
|
||||
import net.psforever.objects.guid.{GUIDTask, TaskResolver}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import scala.concurrent.Await
|
||||
import akka.pattern.ask
|
||||
import akka.util.Timeout
|
||||
import scala.concurrent.duration._
|
||||
|
||||
class GUIDTaskRegister1Test extends Specification {
|
||||
"RegisterObjectTask" should {
|
||||
"register (1)" in {
|
||||
val system = ActorSystem("sys")
|
||||
val test = system.actorOf(Props(classOf[GUIDTaskRegister1TestActor], system), "test")
|
||||
|
||||
implicit val timeout = Timeout(5 seconds)
|
||||
val future = test ? "test"
|
||||
val result = Await.result(future, timeout.duration).asInstanceOf[String]
|
||||
result mustEqual "success"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class GUIDTaskRegister1TestActor(implicit system : ActorSystem) extends Actor {
|
||||
def receive : Receive = {
|
||||
case "test" =>
|
||||
val (_, uns, taskResolver, probe) = GUIDTaskTest.CommonTestSetup
|
||||
val obj = new GUIDTaskTest.TestObject
|
||||
|
||||
assert(!obj.HasGUID)
|
||||
taskResolver ! TaskResolver.GiveTask(new GUIDTaskTest.RegisterTestTask(probe.ref), List(GUIDTask.RegisterObjectTask(obj)(uns)))
|
||||
probe.expectMsg(scala.util.Success)
|
||||
assert(obj.HasGUID)
|
||||
sender ! "success"
|
||||
case _ => ;
|
||||
}
|
||||
}
|
||||
|
||||
//class GUIDTaskRegister1Test extends ActorTest() {
|
||||
// "RegisterObjectTask" in {
|
||||
// val (_, uns, taskResolver, probe) = GUIDTaskTest.CommonTestSetup
|
||||
// val obj = new GUIDTaskTest.TestObject
|
||||
//
|
||||
// assert(!obj.HasGUID)
|
||||
// taskResolver ! TaskResolver.GiveTask(new GUIDTaskTest.RegisterTestTask(probe.ref), List(GUIDTask.RegisterObjectTask(obj)(uns)))
|
||||
// probe.expectMsg(scala.util.Success)
|
||||
// assert(obj.HasGUID)
|
||||
// }
|
||||
//}
|
||||
Loading…
Add table
Add a link
Reference in a new issue