UpForGrabs: Async testability improvements

description

Now that we have async support on EF, questions are starting to come up more often about the best way to implement common testability practices. A common request is to be able to use other IQueryables with the async extension methods defined on EF. These
extension methods require that IQueryables also implement the interface IDbAsyncEnumerable<T> defined by EF to work.

How can we make this easier?

The first approach we are taking for EF6 is to write a "fake query" implementation of IQueryable<T> and IDbAsyncEnumerable<T> and make it available as an example in our documentation. The only problem with this approach is that it takes
more work to copy an paste (and possibly modify) this code to do a relatively simple and reasonable task.

Another alternative would be to have a built in implementation of this "fake queries" in the product.

Yet another alternative would be to make it unnecessary to implement IDbAsyncEnumerable<T> in fakes, e.g. by making the default implementation of the async extension methods fall back to synchronous evaluation when the interface is not available.

file attachments

No files are attached

Closed
by

comments

This is hitting me in jabbr as I just switched to EF 6 and have changed a few areas to use ToListAsync. What would be to nice was if ToListAsync had a default implementation that was either sync or called Task.Run.