title: Using Moq for Generic methods
body: <p>Totally simple situation, but I can't make it work.  I am running into an issue with using Moq to mock a generic method (in this case, on a Ninject Kernel interface):</p>
  
  <pre><code>T Get&lt;T&gt;();
  </code></pre>
  
  <p>I set up my mock object:</p>
  
  <pre><code>Mock&lt;IKernel&gt; mockKernel = new Mock&lt;IKernel&gt;();
          mockKernel.Setup(x =&gt; x.Get&lt;IGetUserQuery&gt;()).Returns(new GetUserQuery());
  </code></pre>
  
  <p>At runtime I get the following exception:</p>
  
  <pre><code>Expression references a method that does not belong to the mocked object: x =&gt; x.Get&lt;IGetUserQuery&gt;(new[] {  })
  </code></pre>
  
  <p>Any idea why it's throwing this?  I've mocked generics in Moq before without a problem...  are there cases in which generic mocking isn't supported?  This seems like a straightforward case.  The only wrinkle is that IGetUserQuery in turn inherits from a genericized type:</p>
  
  <pre><code>IGetUserQuery : ICommand&lt;UserQueryInput, UserQueryOutput&gt;
  </code></pre>
  
  <p>I don't see this creating a problem because the generic types for this implementation of ICommand are staticly defined by IGetUserQuery, so I doubt this is confusing Moq.</p>
  
  <p>Thanks in advance</p>