[英]How to stop TestProbe in Akka.Net
我需要測試演員對Terminated
消息是否正確做出反應,並使用TestProbe
模擬它的孩子。 但是由於某種原因,我無法阻止TestProbe
演員。 這是測試:
[Test]
public void TestProbeStopTest()
{
var probe = CreateTestProbe("Test");
Watch(probe);
Sys.Stop(probe);
ExpectTerminated(probe);
}
結果如下:
Failed: Timeout 00:00:03 while waiting for a message of type Akka.Actor.Terminated Terminated Akka.TestKit.TestProbe.
at NUnit.Framework.Assert.Fail(String message, Object[] args)
at Akka.TestKit.TestKitBase.InternalExpectMsgEnvelope[T](Nullable`1 timeout, Action`2 assert, String hint, Boolean shouldLog)
at Akka.TestKit.TestKitBase.InternalExpectMsgEnvelope[T](Nullable`1 timeout, Action`1 msgAssert, Action`1 senderAssert, String hint)
at Akka.TestKit.TestKitBase.InternalExpectMsg[T](Nullable`1 timeout, Action`1 msgAssert, String hint)
at Akka.TestKit.TestKitBase.ExpectTerminated(IActorRef target, Nullable`1 timeout, String hint)
at Actors.Tests.Common.RootActorTests.TestProbeStopTest()
感謝@Horusiath,此代碼有效
[Test]
public void TestProbeStopTest()
{
var probe = CreateTestProbe("Test");
Watch(probe.Ref);
Sys.Stop(probe.Ref);
ExpectTerminated(probe.Ref);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.