title: Unit Testing IServiceCollection Registration
body: <p>I'm trying to figure out the easiest way to test my Service Registrations method for my framework. I'm creating dynamic services my registration looks like so:</p>
  
  <pre><code>var messageHubConfig = new DynamicHubServiceConfiguration&lt;Message, MessageDTO&gt;();
  messageHubConfig.SetDynamicHubOptions&lt;AstootContext&gt;(async (context, dto) =&gt;
  {
      return await context.ConversationSubscriptions
                          .Where(x =&gt; x.ConversationId == dto.ConversationId 
                                 &amp;&amp; x.IsSubscribed)
                          .Distinct()
                          .Select(x =&gt; x.User.UniqueIdentifier)
                          .ToListAsync();
  });
  
  messageHubConfig.RequiresDynamicValidator = false;
  messageHubConfig.EventMapping.AddCreateEvent(async (sp, obj, dto) =&gt;
  {
      var conversationService = sp.GetService&lt;IRestEzService&lt;Conversation, ConversationDTO&gt;&gt;();
      var conversationDTO = await conversationService.Get(new object[] { dto.ConversationId });
      var hubTaskQueue = sp.GetService&lt;IHubServiceTaskQueue&gt;();
      hubTaskQueue.QueueDynamicCreate(conversationDTO);
  }).When(async (sp, dto) =&gt; {
      var context = sp.GetService&lt;AstootContext&gt;();
      return await context.Conversations.Where(x =&gt; x.Id == dto.ConversationId).Where(x =&gt; x.Messages.Count == 1).AnyAsync();
  });
  
  //Registers service with a hub
  restConfiguration.RegisterRestService(typeof(IMessageDTOService), 
                                        typeof(MessageDTOService), 
                                        messageHubConfig);
  </code></pre>
  
  <p>Inside of my Register Rest Service Method I have a lot of different services Getting registered e.g:</p>
  
  <pre><code>services.AddTransient(restServiceType, (IServiceProvider serviceProvider) =&gt;
  {
      var restService = (IRestEzService&lt;TEntity, TDTO&gt;)
          ActivatorUtilities.CreateInstance(serviceProvider, restServiceImplementationType);
      serviceOption.EventMapping?.Register(serviceProvider, restService);
  
      return restService;
  });
  </code></pre>
  
  <p>How can I be assure that my factory configuration is being registered properly, How can I create a Service Collection for testing?</p>