I have an actor that responds to a message by sending a message to it's parent, like this...
public void Handle(string message)
{
Context.Parent.Tell("Hello");
}
I now want to test that the message is sent to the Actors Parent, but can't figure out how. My current test looks like the following...
pubilc void AllResponsesWillGoToParent()
{
ActorOf<MyActor>().Tell("Respond to parent");
ExpectMsg<string>(x => x == "Hello");
}
This of course doesn't work because the actors parent is the test ActorSystem and not the actor assigned to the TestActor property.
Does anyone know how I can test that the message is indeed sent to it's Parent, thanks.
One option to solve this is to create fake parent, that is creating a real child actor that you are testing. This parent will forwarding message from child to a test probe or to TestActor itself.
more patterns here http://hs.ljungblad.nu/post/69922869833/testing-parent-child-relationships-in-akka let me know if you will need a c# snippet