title: Mocking generic method call for any given type parameter
body: <p>I have an interface</p>
  
  <pre><code>public interface IDataProvider
  {
      T GetDataDocument&lt;T&gt;(Guid document) where T:class, new()
  }
  </code></pre>
  
  <p>I'd like to mock it in a way, that it would just return a new instance of a given type, regardless of the exact type, something like:</p>
  
  <pre><code>myMock.Setup(m =&gt; m.GetDataDocument&lt;It.IsAny&lt;Type&gt;()&gt;(It.IsAny&lt;Guid&gt;()))
  .Returns(() =&gt; new T());
  </code></pre>
  
  <p>(which doesn't work of course, because I cannot just give any type parameter to moq, and I can't know which type must be returned.</p>
  
  <p>Any ideas on this one?</p>