I have the following C# code to test an AKKA.NET actor's behavior. The statement productActor.Tell(new ChangeActiveStatus(true));
is expected to be a blocking call (TestKit makes it a synchronous call as per this blog) but I'm seeing it returns immediately. As a result, the second test fails although the ActiveStatus will be changed later.
[TestMethod]
public void ProductActorUnitTests_CheckFor_ActiveStatusChanged()
{
var productActor = ActorOfAsTestActorRef<ProductActor>();
Assert.IsTrue(ProductActor.UnderlyingActor.ActiveStatus == false, "The initial ActiveStatus is expected to be FALSE.");
productActor.Tell(new ChangeActiveStatus(true));
Assert.IsTrue(productActor.UnderlyingActor.ActiveStatus == true, "The new ActiveStatus is expected to be TRUE.");
}
****** UPDATE *****
The following code with a Thread.Sleep(10000) succeeds:
[TestMethod]
public void ProductActorUnitTests_CheckFor_ActiveStatusChanged()
{
var productActor = ActorOfAsTestActorRef<ProductActor>();
Assert.IsTrue(ProductActor.UnderlyingActor.ActiveStatus == false, "The initial ActiveStatus is expected to be FALSE.");
productActor.Tell(new ChangeActiveStatus(true));
Thread.Sleep(10000);
Assert.IsTrue(productActor.UnderlyingActor.ActiveStatus == true, "The new ActiveStatus is expected to be TRUE.");
}