title: Moq with Autofac Func<Owned<IClass>>
body: <p>I'm trying to swtich some code I have to use Owned Instances instead of passing around the container.</p>
  
  <pre><code>public class SyncManager
  {
      private Func&lt;Owned&lt;ISynchProcessor&gt;&gt; _syncProcessor = null;
  
      public SyncManager(Func&lt;Owned&lt;ISynchProcessor&gt;&gt; syncProcessor)
      {
          _syncProcessor = syncProcessor;
      }
  
      private void Handle()
      {
          using (var service = _syncProcessor())
          {
              service.Value.Process();   
          }
      }
  }
  </code></pre>
  
  <p>Now I want to Moq the Func&lt; Owned> and inject it but the calls to _syncProcessor() don't resolve anything So I tried this. </p>
  
  <pre><code>Mock&lt;ITimer&gt; timer = new Mock&lt;ITimer&gt;();
  Mock&lt;Func&lt;Owned&lt;ISynchProcessor&gt;&gt;&gt; syncProcessor = new Mock&lt;Func&lt;Owned&lt;ISynchProcessor&gt;&gt;&gt;();
  Mock&lt;Owned&lt;ISynchProcessor&gt;&gt; proc = new Mock&lt;Owned&lt;ISynchProcessor&gt;&gt;();
  
  [TestInitialize]
  public void TestInitialize()
  {
      timer = new Mock&lt;ITimer&gt;();
      syncProcessor = new Mock&lt;Func&lt;Owned&lt;ISynchProcessor&gt;&gt;&gt;();
      syncProcessor.Setup(item =&gt; item.Invoke()).Returns(() =&gt; proc.Object);
  }
  </code></pre>
  
  <p>but that gives me a run time error that it can't cast object of type System.Linq.Expressions.InstanceMethodCallExpressionN to type System.Linq.InvocationExpression</p>