title: Moq - Linq expression in repository - Specify expression in setup
body: <p>I have a method on my interface that looks like:</p>
  
  <pre><code>T GetSingle(Expression&lt;Func&lt;T, bool&gt;&gt; criteria);
  </code></pre>
  
  <p>I'm trying to mock the setup something like this (I realise this isn't working):</p>
  
  <pre><code>_mockUserRepository = new Mock&lt;IRepository&lt;User&gt;&gt;();
  _mockUserRepository.Setup(c =&gt; c.GetSingle(x =&gt; x.EmailAddress == "a@b.com"))
      .Returns(new User{EmailAddress = "a@b.com"});
  </code></pre>
  
  <p>I realise I'm passing in the wrong parameter to the setup.<br>
  After reading <a href="https://stackoverflow.com/a/6626016/131809">this answer</a> I can get it working by passing in the Expression, like this:</p>
  
  <pre><code>_mockUserRepository.Setup(c =&gt; c.GetSingle(It.IsAny&lt;Expression&lt;Func&lt;User, bool&gt;&gt;&gt;())
      .Returns(new User{EmailAddress = "a@b.com"});
  </code></pre>
  
  <p>However, this means if I call the <code>GetSingle</code> method with any expression, the same result is returned.</p>
  
  <p>Is there a way of specifying in the setup, what Expression to use?</p>