title: Autofac ILiftetimeScope.ResolveKeyed in unit test
body: <p>I recently started using Autofac after years of working with Unity, so I'm running into some (newbie?) problems now and then.. 
  Right now I have the following situation: a Factory class that uses <code>ILifetimeScope.ResolveKeyed</code> to return a specific repository, eg:</p>
  
  <pre><code>scope.ResolveKeyed&lt;IDocumentRepository&gt;(EncryptionLevel.None, new NamedParameter("container", "test"))
  </code></pre>
  
  <p>In my unit test (using AutoFac.Extras.AutoMock) I have:</p>
  
  <pre><code>using (var mock = AutoMock.GetLoose())
  {
      mock.Mock&lt;IDocumentRepository&gt;().Setup(m =&gt; m.GetByIdAsync(It.IsAny&lt;Guid&gt;())).Returns(Task.FromResult("hello"));
  }
  </code></pre>
  
  <p>The problem occurs in a unit test, it says </p>
  
  <blockquote>
    <p>The requested service 'None (Blob.IDocumentRepository)' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.</p>
  </blockquote>
  
  <p>I tried to mock the <code>ILifetimeScope</code> and let it return my mocked <code>IDocumentRepository</code>, but apparently that is <a href="https://github.com/autofac/Autofac.Extras.Moq/issues/8" rel="nofollow noreferrer">not possible</a>.</p>
  
  <p>So what can I do to make the <code>ILifetimeScope</code> resolve my mocked <code>IDocumentRepository</code>?</p>