我是 Akka.NET 的新手,目前我很难测试我的演员是否向自己发送了任何消息。
这是我的演员代码:
public class MySuperActor : ReceiveActor
{
private readonly IActorRef _anotherActor;
public RoteadorDeContratosSuspensoActor(IActorRef anotherActor)
{
_anotherActor = anotherActor;
Receive<MySuperActorMessage>(m => HandleMessage(m));
Receive<MySuperActorSuperMessage>(m => HandleSuperMessage(m));
}
private void HandleMessage(MySuperActorMessage message)
{
Self.Tell(new MySuperActorSuperMessage(message));
}
private void HandleSuperMessage(MySuperActorSuperMessage message)
{
_anotherActor.Tell(new AnotherActorMessage(message));
}
}
那是我的测试代码
[TestFixture]
public class MySuperActorTest : TestKit
{
private IActorRef _sut;
private IActorFactory _actorFactory;
private List<Contrato> _contratos;
private Props _props;
[Test]
public void WhenReceiveASimpleMessageActorShouldSendSuperMessageToHimself()
{
var testProbe = CreateTestProbe();
Props props = Props.Create<MySuperActor>(testProbe);
var sut = ActorOf(_props);
sut.Tell(new MySuperActorMessage());
ExpectMsg<MySuperActorSuperMessage>();
}
}
我的测试总是会出现以下消息:
失败:等待 AkkaNetTestPlaygroung.MySuperActorSuperMessage 类型的消息时超时 00:00:03
如何检查我的演员是否正在向自己发送另一条消息?