This package looks useful. Unfortunately however, it doesn't solve the problem of calling async methods on IQueryable objects.
For example, calling .ToListAsync() on my mock queryable still throws:
System.InvalidOperationException : The source IQueryable doesn't implement IAsyncEnumerable<MyClass>. Only sources that implement IAsyncEnumerable can be used for Entity Framework asynchronous operations.
public class ApplicationControllerTests
{
private static IEnumerable<Application> GetApplications() => new[]
{
new Application
{
...
},
...
};
[Fact]
public async Task GetApplicationsReturnsExpected()
{
//Arrange
var applications = GetApplications()
.AsQueryable()
.BuildMock();
var fixture = ApplicationControllerFixture.Create();
fixture.QueryService
.Setup(s => s.GetApplications())
.Returns(applications.Object);
//Act
var result = await fixture.Controller.GetApplications();
//Assert
var response = Assert.IsType<OkObjectResult>(result);
}
}
[ApiController]
public class ApplicationController : ControllerBase
{
[HttpGet]
public async Task<IActionResult> GetApplications()
{
LogActivity(nameof(GetApplications), Request);
var list = await QueryService.GetApplications(ClientId)
.ToListAsync();
return Ok(list);
}
}
This package looks useful. Unfortunately however, it doesn't solve the problem of calling async methods on
IQueryable
objects.For example, calling .ToListAsync() on my mock queryable still throws:
System.InvalidOperationException : The source IQueryable doesn't implement IAsyncEnumerable<MyClass>. Only sources that implement IAsyncEnumerable can be used for Entity Framework asynchronous operations.