title: Moq setup not returning expected object, mismatched invocation
body: <p>I have the following piece of code that I'm trying to mock out using Moq, specifically  _userRepository.Find():</p>
  
  <pre><code>List&lt;string&gt; importEmails = ocrImportCentres.Select(c =&gt; c.CentreAdministratorEmail).Where(e =&gt; !string.IsNullOrWhiteSpace(e)).ToList();
  
   var existingUsersWithEmail =
              _userRepository.Find(
                  x =&gt;
                      importEmails.Contains(
                          x.PersonalDetailsHistory.OrderByDescending(h =&gt; h.DateCreated).FirstOrDefault().Email))
                  .Select(o =&gt; new
                  {
                      o.PersonalDetailsHistory.FirstOrDefault().Email,
                      (o as OCRInstitutionAdmin).UniqueId 
                  });
  </code></pre>
  
  <p>The Find() methods are defined within IRepository:</p>
  
  <pre><code>IQueryable&lt;T&gt; Find(Expression&lt;Func&lt;T, bool&gt;&gt; predicate);
  IQueryable&lt;T&gt; Find(Expression&lt;Func&lt;T, bool&gt;&gt; predicate = null, Func&lt;IQueryable&lt;T&gt;, IOrderedQueryable&lt;T&gt;&gt; orderBy = null, string includeProperties = "");
  </code></pre>
  
  <p>Moq setup within my unit test:</p>
  
  <pre><code>_userRepository.Setup(
              x =&gt;
                  x.Find(It.IsAny&lt;Expression&lt;Func&lt;User, bool&gt;&gt;&gt;(),
                      It.IsAny&lt;Func&lt;IQueryable&lt;User&gt;, IOrderedQueryable&lt;User&gt;&gt;&gt;(), It.IsAny&lt;string&gt;()))
              .Returns(existingAdmins.AsQueryable);
  </code></pre>
  
  <p>However when the unit test is ran _userRepository.Find() doesn't return the expected test object, after looking at the _userRepository.Verify(); I can see that my setup doesn't match the perform invocation and hence why I don't get my expected object returned.</p>
  
  <p>Performed invocations:</p>
  
  <pre><code>IRepository`1. Find(x =&gt; value(OCRExamCreator.BusinessLogic.Services.OCRImportCentreManagementService+&lt;&gt;c__DisplayClasse).importEmails.Contains(x.PersonalDetailsHistory.OrderByDescending(h =&gt; h.DateCreated).FirstOrDefault().Email))
  </code></pre>
  
  <p>I did have the unit test passing and the Moq _userRepository.Setup working until I had to change the _userRepository.Find() LINQ to prevent the following exception:</p>
  
  <pre><code>{"Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries."}
  </code></pre>
  
  <p>I have tried changing  _userRepository.Setup() however I can't get it to return the test data I need, any help/pointers would be much appreciated</p>