I have this Moq setup:
_mockContext.Setup(x => x.CarSections).Returns(new List<CarSection> { _carSection }.ToDbSet());
Which basically assigns the List to the entity of DbContext.CarSections.
One of the methods is an async method. Something like:
public async Task<CarSection> GetSectionAsync(int sectionId)
{
return await _context
.CarSections
.FirstOrDefaultAsync(s => s.CarSectionId == sectionId && s.StatusCode == 4);
}
When it goes through that method I'm getting the error:
The provider for the source
IQueryable
doesn't implementIDbAsyncQueryProvider
. Only providers that implementIDbAsyncQueryProvider
can be used for Entity Framework asynchronous operations.
Which I believe is because of the .ToDbSet(). Already tried with Task.FromResult(new List<CarSection>{ _carSection }
but the .Returns expects a "DbSet" and not a "Task".
Any ideas on how to workaround this?