title: Mocking Task<IEnumerable<T>> with NSubstitute
body: <p>I'm having issues trying to get <code>NSubstitute</code> to return an <code>IEnumerable</code> interface from a <code>Task</code>.</p>
  
  <p>The factory I'm mocking:</p>
  
  <pre><code>public interface IWebApiFactory&lt;T&gt; : IDisposable
  {
      &lt;T&gt; GetOne(int id);
      Task&lt;IEnumerable&lt;T&gt;&gt; GetAll();
      Task&lt;IEnumerable&lt;T&gt;&gt; GetMany();
      void SetAuth(string token);
  }
  </code></pre>
  
  <p>The test method:</p>
  
  <pre><code>[TestMethod]
  public async Task TestMutlipleUsersAsViewResult()
  {
      var employees = new List&lt;EmployeeDTO&gt;()
      {
          new EmployeeDTO(),
          new EmployeeDTO()
      };
  
      // Arrange
      var factory = Substitute.For&lt;IWebApiFactory&lt;EmployeeDTO&gt;&gt;();
      factory.GetMany().Returns(Task.FromResult(employees));
  }
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <blockquote>
    <p>cannot convert from 'System.Threading.Tasks.Task> to System.Func>></p>
  </blockquote>
  
  <p>Is this an issue with me passing a list, as a posed to <code>IEnumerable</code> even though <code>List</code> is <code>IEnumerable</code>?</p>
  
  <p>Edit:</p>
  
  <p>These are the functions within <code>NSubstitute</code></p>
  
  <pre><code>public static ConfiguredCall Returns&lt;T&gt;(this T value, Func&lt;CallInfo, T&gt; returnThis, params Func&lt;CallInfo, T&gt;[] returnThese);
  public static ConfiguredCall Returns&lt;T&gt;(this T value, T returnThis, params T[] returnThese);
  </code></pre>