I have an Actor that takes in a message and does a context become as soon as it gets that message. After that I spin up an Observable and in that Observable, I keep sending this Actor some specific messages until I get to a desired state. I then started to write unit tests to test this Actor behavior, but I would like to know how I can check the expectations. So here is my test Actor:
"start to RampUp when a Dispatch command is sent" in {
rampUpTypeSimActor ! Dispatch(rampUpTypeCfg.maxPower)
expectMsgPF(12.seconds) {
case state: PowerPlantState =>
// check the signals
assert(
state.signals(activePowerSignalKey).toDouble === 800.0,
"expecting activePower to be 800.0, but was not the case"
)
assert(
state.signals(isDispatchedSignalKey).toBoolean,
"expected isDispatched signal to be true, but was false instead"
)
assert(
state.signals(isAvailableSignalKey).toBoolean,
"expected isAvailable signal to be true, but was false instead"
)
assert(
state.rampRate === initPowerPlantState.rampRate,
"rampRate did not match"
)
assert(
state.setPoint === initPowerPlantState.setPoint,
"setPoint did not match"
)
case x: Any => // If I get any other message, I fail
fail(s"Expected a PowerPlantState as message response from the Actor, but the response was $x")
}
}
How can I wait for 15 seconds after sending the Dispatch command? I need to send another command called Status so that I can check my expectations, but I want to wait for 15 seconds and then send the Status message to my actor!
Any suggestions?