title: NSubstitute mocking Mongo IFindFluent does not work
body: <p>I was doing dome unit tests around my repository, until I got a strange error. Searched around to see if I was not making known mistakes, I could simplify it and notice that I am getting the same error.
  Looks like I cannot mock IFindFluent interface properly, and I would like to know what I am doing wrong. This test:</p>
  
  <pre><code>    [Fact]
      public void Test()
      {
          var ff = Substitute.For&lt;IFindFluent&lt;string, string&gt;&gt;();
          ff.FirstOrDefaultAsync().Returns("asd");
      }
  </code></pre>
  
  <p>is returning this error message:</p>
  
  <blockquote>
    <p>NSubstitute.Exceptions.CouldNotSetReturnDueToTypeMismatchException :
    Can not return value of type Task`1 for IDisposable.Dispose (expected
    type Void).</p>
    
    <p>Make sure you called Returns() after calling your substitute (for
    example: mySub.SomeMethod().Returns(value)), and that you are not
    configuring other substitutes within Returns() (for example, avoid
    this: mySub.SomeMethod().Returns(ConfigOtherSub())).</p>
    
    <p>If you substituted for a class rather than an interface, check that
    the call to your substitute was on a virtual/abstract member. Return
    values cannot be configured for non-virtual/non-abstract members.</p>
    
    <p>Correct use:
        mySub.SomeMethod().Returns(returnValue);</p>
    
    <p>Potentially problematic use:
        mySub.SomeMethod().Returns(ConfigOtherSub()); Instead try:
        var returnValue = ConfigOtherSub();
        mySub.SomeMethod().Returns(returnValue);</p>
    
    <p>at
    NSubstitute.Core.ConfigureCall.CheckResultIsCompatibleWithCall(IReturn
    valueToReturn, ICallSpecification spec)    at
    NSubstitute.Core.ConfigureCall.SetResultForLastCall(IReturn
    valueToReturn, MatchArgs matchArgs)    at
    NSubstitute.Core.SubstitutionContext.LastCallShouldReturn(IReturn
    value, MatchArgs matchArgs)    at
    CorporateActions.Tests.Persistence.RepositoryTests.Test()</p>
  </blockquote>
  
  <p>I've searched around, but most common mistakes about it does not fit with this simple implementation. Any thoughts why does this not work?</p>