title: Mocking objects with Moq when constructor has parameters
body: <p>I have an object I'm trying to mock using moq. The object's constructor has required parameters:</p>
  
  <pre><code>public class CustomerSyncEngine {
      public CustomerSyncEngine(ILoggingProvider loggingProvider, 
                                ICrmProvider crmProvider, 
                                ICacheProvider cacheProvider) { ... }
  }
  </code></pre>
  
  <p>Now I'm trying to create the mock for this object using either moq's v3 "setup" or v4 "Mock.Of" syntax but can't figure this out... everything I'm trying isn't validating. Here's what I have so far, but the last line is giving me a real object, not the mock. The reason I'm doing this is because I have methods on the CustomerSyncEngine I want to verify are being called...</p>
  
  <pre><code>// setup
  var mockCrm = Mock.Of&lt;ICrmProvider&gt;(x =&gt; x.GetPickLists() == crmPickLists);
  var mockCache = Mock.Of&lt;ICacheProvider&gt;(x =&gt; x.GetPickLists() == cachePickLists);
  var mockLogger = Mock.Of&lt;ILoggingProvider&gt;();
  
  // need to mock the following, not create a real class like this...
  var syncEngine = new CustomerSyncEngine(mockLogger, mockCrm, mockCache);
  </code></pre>