title: Akka.Net test Child actor creation/supervision with TestKit
body: <p>I have Akka.Net code similar to the following and I am trying to write tests for it:</p>
  
  <pre><code>public class DoesSomethingActor : UntypedActor
  {
      protected override void OnReceive(object message)
      {
  
      }
  }
  
  public class ForwardsMessagesActor : UntypedActor
  {
      protected override void OnReceive(object message)
      {
          var actor = Context.ActorOf(Context.DI().Props&lt;DoesSomethingActor&gt;(), "DoesSomethingWorker");
  
          for (int i = 0; i &lt; 5; i++)
          {
              actor.Tell(message + " " + i);
          }
      }
  }
  </code></pre>
  
  <p>I have got this test working but I am clearly missing something since I am not using much of TestKit at all. Is there still no official documentation for how to test this using TestKit ? </p>
  
  <pre><code>//creating actor mocks with Moq seems to confuse Akka - it just doesn't work 
  //but creating mock classes manually like this, 
  //then configuring them in the DI container works
  public class DoesSomethingActorSpy : DoesSomethingActor
  {
      public static List&lt;object&gt; ReceivedMessages = new List&lt;object&gt;();
  
      protected override void OnReceive(object message)
      {
          ReceivedMessages.Add(message);
      }
  }
  
      [TestMethod]
      public void ForwardsMessagesActor_Creates5Messages()
      {
          //set up DI container to use DoesSomethingActorSpy as a child actor
          ContainerBuilder builder = new ContainerBuilder();
          builder.RegisterType&lt;ForwardsMessagesActor&gt;();
          builder.RegisterType&lt;DoesSomethingActorSpy&gt;().As&lt;DoesSomethingActor&gt;();
          IContainer container = builder.Build();
  
          var propsResolver = new AutoFacDependencyResolver(container, Sys);
  
          var actor = ActorOfAsTestActorRef&lt;ForwardsMessagesActor&gt;(propsResolver.Create&lt;ForwardsMessagesActor&gt;());
  
          actor.Tell("Test");
  
          //this looks wrong, I probably should be using something from TestKit
          Thread.Sleep(10);
  
          CollectionAssert.AreEquivalent(
              new[] { "Test 0", "Test 1", "Test 2", "Test 3", "Test 4" },
              DoesSomethingActorSpy.ReceivedMessages);
      }
  </code></pre>
  
  <p>How should I create mock actors? Is there any method on TestKit I can call to wait until all messages have been processed?</p>