【问题标题】:How to stop TestProbe in Akka.Net如何在 Akka.Net 中停止 TestProbe
【发布时间】:2017-01-09 13:19:40
【问题描述】:

我需要测试我的演员对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() 

【问题讨论】:

标签: c# akka akka.net


【解决方案1】:

感谢@Horusiath,此代码有效

[Test]
public void TestProbeStopTest()
{
    var probe = CreateTestProbe("Test");
    Watch(probe.Ref);
    Sys.Stop(probe.Ref);
    ExpectTerminated(probe.Ref);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-13
    • 2019-07-16
    • 1970-01-01
    • 2019-09-24
    • 2017-10-17
    相关资源
    最近更新 更多