I would like to use Akka.net TestKit for writing Unit tests, but I have a question. I have a class SubscriptionService which is responsible for transmitting messages to the selected actors.
public class SubscriptionService : ReceiveActor
{
private readonly ActorSelection service1;
private readonly ActorSelection service2;
public SubscriptionService()
{
this.service1 = Context.ActorSelection("Service1");
this.service2 = Context.ActorSelection("Service2");
this.Receive<RequestMessage>(message => this.ProcessRequestMessage(message));
}
private void ProcessRequestMessage(RequestMessage message)
{
this.service1.Tell(message);
this.service2.Tell(message);
}
How can I test this behavior? I created this test but in this test I get the exception. "Additional information: Assert.Fail failed. Failed: Timeout 00:00:03 while waiting for a message"
[TestClass]
public class SubscriptionServiceUnitTests : TestKit
{
[TestMethod]
public void Test1()
{
var subscriptionServiceRef = this.ActorOfAsTestActorRef<SubscriptionService>("SubscriptionService");
subscriptionServiceRef.Tell(new RequestMessage());
var answer = this.ExpectMsg<RequestMessage>();
}
I mean How can I get message for service1 and service2 in Test1 method ?