title: How can you use Lazy<> with AutoMock (Moq)
body: <p>We are using Autofac.Extras.Moq.AutoMock.
  Now I have a constructor dependency using Lazy&lt;></p>
  
  <pre><code>public MyService(Lazy&lt;IDependency&gt; myLazyDependency) {...}
  </code></pre>
  
  <p>to test <code>MyService</code> we need to mock the <code>Lazy&lt;Dependency&gt;</code>.</p>
  
  <p>I am trying this with</p>
  
  <pre><code>[ClassInitialize]
  public static void Init(TestContext context)
  {
      autoMock = AutoMock.GetLoose();
  }
  
  [TestInitialize]
  public void MyTestInitialize()
  {
       var myDepMock = autoMock.Mock&lt;Lazy&lt;IDependency&gt;&gt;();  // &lt;-- throws exception
  }
  </code></pre>
  
  <p>This is the exception returned by the test runner:</p>
  
  <p>Initialization method Tests.MyServiceTests.MyTestInitialize threw exception. System.InvalidCastException: System.InvalidCastException: Unable to cast object of type 'System.Lazy<code>1[IDependency]' to type 'Moq.IMocked</code>1[System.Lazy`1[IDependency]]'..</p>
  
  <p>So, how can I pass a Lazy&lt;> mocked object using automock.  </p>