Relative Content

Tag Archive for c#asynchronousmocking

Cannot mock async method in C# & EF Core 8

I tried to test an async repo method, I mocked dbcontext, and did same as Microsoft’s documentation suggested (https://learn.microsoft.com/en-us/ef/ef6/fundamentals/testing/mocking?redirectedfrom=MSDN#testing-with-async-queries).

Cannot mock async method in C# EF 8

I tried to test async repo method, I mocked dbcontext, and did same as microsoft’s documentaiton suggested (https://learn.microsoft.com/en-us/ef/ef6/fundamentals/testing/mocking?redirectedfrom=MSDN#testing-with-async-queries), I use the .net 8.0,
at the last step var blogs = service.GetAllBlogsAsync().Result;
I will get this error
System.AggregateException: ‘One or more errors occurred. (The source ‘IQueryable’ doesn’t implement ‘IAsyncEnumerable<TestAsync.Blog>’. Only sources that implement ‘IAsyncEnumerable’ can be used for Entity Framework asynchronous operations.)’
anyone can help, thanks.