title: Moq a function with anonymous type
body: <p>I'm trying to mock this method</p>
  
  <pre><code>Task&lt;TResult&gt; GetResultAsync&lt;TResult&gt;(Func&lt;string, TResult&gt; transformFunc)
  </code></pre>
  
  <p>like this</p>
  
  <pre><code>iMock.Setup(m =&gt; m.GetResultAsync(It.IsAny&lt;Func&lt;string, object&gt;&gt;())).ReturnsAsync(new { isPair = false });
  </code></pre>
  
  <p>The method to test doing the call passing an anonymous type to the generic parameter like this</p>
  
  <pre><code>instance.GetResultAsync(u =&gt; new {isPair = u == "something" }) //dont look at the function return because as generic could have diferent implementations in many case
  </code></pre>
  
  <p>Moq never matches my GetResultAsync method with the parameters sent.</p>
  
  <p>I'm using Moq 4</p>