title: Passing a predicate function parameter in moq fails
body: <p>I am trying to use moq to mock a function on my licence class.</p>
  
  <p>The licence class has the following interface:</p>
  
  <pre><code>Licence TryGetLicence(Predicate&lt;Licence&gt; filter);
  </code></pre>
  
  <p>In my integration test I am using mef to lazy load objects. My class finds the mef loaded objects and needs to check if there are licences available. For my test I create two objects, one of which can be licenced. I want to use moq to only return a licence for this object and null for the other, just as the real class would. The problem I am having is that moq doesn’t like me passing in a predicate. I’m not sure if moq just doesn’t handle predicates in this way or am I just implementing this wrong?</p>
  
  <p>Here are the lines of code I have in my test that sets up moq for the above interface:</p>
  
  <pre><code>var lic = new Licence
  {
     LicId = Guid.Parse("53024D4E-3A01-4489-A341-753D04748EB9"),
     LicName = "test",
     Count = 1,
     ExpiryDate = DateTime.Now.AddDays(2)
  };
  
  var mockAgent = new Mock&lt;ILicenceAgent&gt;();
  mockAgent.Setup(x =&gt; x.TryGetLicence (y =&gt; y.LicId == lic.LicId)) Returns(lic);
  </code></pre>
  
  <p>This builds but when the last line is hit it throws an Unsupported expression exception.</p>
  
  <p>For other tests I have used:</p>
  
  <pre><code>mockAgent.Setup(x =&gt; x. TryGetLicence (It.IsAny&lt;Predicate&lt;Licence&gt;&gt;())).Returns(lic);
  </code></pre>
  
  <p>I can’t use this for my new test as it would return a valid licence for both objects I have loaded. </p>
  
  <p>Can moq be used in the way I am trying to use it?</p>