title: Mock DbQuery to use FromSql from unit tests
body: <p>I am using EF Core in a projet to get stored procedure calling. In my context i have the following :</p>
  
  <pre><code>public class MyContext : DbContext
  {
      public DbQuery&lt;User&gt; UserQuery { get; set; }
  
      public MyContext(DbContextOptions&lt;MyContext&gt; options) : base(options) { }
  }
  </code></pre>
  
  <p>And i call the stored procedure like this :</p>
  
  <pre><code>public virtual async Task&lt;User&gt; GetUserAsync(string name)
  {
      return await MyContext.Query&lt;User&gt;()
          .FromSql($"EXEC [dbo].[GetUser], @Login = {name}")
          .FirstOrDefaultAsync();
  }
  </code></pre>
  
  <p>Code is working fine. I need to test this method in unit tests, i'm using InMemoryDatabase to mock my context MyContext like this :</p>
  
  <pre><code>[Fact]
  public async Task GetUserAsync_should_return_first_user_with_login_and_password_if_exists()
  {
      // Arrange
      var users = new List&lt;User&gt;
      {
          new User()
          {
              Login = "test@outlook.fr",
              Password = "pass1",
          },
      };
  
      var options = new DbContextOptionsBuilder&lt;MyContext&gt;()
          .UseInMemoryDatabase(databaseName: "BddName")
          .Options;
      var context = new MyContext(options);
      var loginProvider = A.Fake&lt;LoginProvider&gt;(opts =&gt; opts.WithArgumentsForConstructor(() =&gt; new LoginProvider(context)));
  
  
      // Act
  
      // Assert
      context.Dispose();
  }
  </code></pre>
  
  <p>And i have no idea how can i set my list into the result of the stored procedure called from DbQuery. I tried to follow this article : <a href="https://nodogmablog.bryanhogan.net/2017/11/unit-testing-entity-framework-core-stored-procedures/" rel="nofollow noreferrer">https://nodogmablog.bryanhogan.net/2017/11/unit-testing-entity-framework-core-stored-procedures/</a> but it works for DbSet only and not DbQuery.
  I need some advices for this case.</p>
  
  <p>Thanks in advance.</p>