title: Mocking IIndex<TKey, TValue>
body: <p>I'using IIndex as factory to decide wich service to use. When I'm trying to unit test my CommunicationJob class I'm struggling with the mock of IIndex.</p>
  
  <pre><code>public class CommunicationJob : BaseJob
  {
      private readonly IRepo&lt;Notification&gt; _nr;
      private readonly IIndex&lt;string, IService&gt; _cs;
  
      public CommunicationJob
      (
          IRepo&lt;Notification&gt; nr,
          IIndex&lt;string, IService&gt; cs
      )
      {
          _nr= nr;
          _cs= cs;
      }
  
      public void Do(DateTime date)
      {
          foreach (var n in _nr.GetList())
          {
              _cs[n.GetType().Name].Send(n);
  
              nr.Sent = DateTime.Now;
              nr.Update(n, true);
          }
      }
  }
  </code></pre>
  
  <p>And the problem is that this is _cs[n.GetType().Name] null.
  Has anyone any solution to my problem? One solution could be to initiate Autofac before the test, but I don't know how to load AutoFac in the test context. </p>
  
  <p>My test look like this:</p>
  
  <pre><code>[Theory]
  [InlineData(0)]
  [InlineData(1)]
  [InlineData(2)]
  [InlineData(3)]
  public void WithNotifications(int numberOfNotifications)
  {
      var fixture = new TestCommunicationJobFixture();
  
      var sut = fixture.WithNotifications(numberOfNotifications).GetSut();
      sut.Do(new DateTime());
  
      fixture.MockCommunicationService.Verify(x =&gt; x["EmailNotification"].Send(It.Is&lt;Notification&gt;(z =&gt; z.Sent != null)), Times.Exactly(numberOfNotifications));
      fixture.MockNotificationRepo.Verify(x =&gt; x.Update(It.Is&lt;Notification&gt;(z =&gt; z.Sent != null), true), Times.Exactly(numberOfNotifications));
  }
  </code></pre>