3
Vote

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.

comments

dfowler wrote Jul 23, 2013 at 1:56 AM

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.

divega wrote Aug 14, 2013 at 8:20 AM

We previously discussed doing this in 6.1 so clearing up release field.