Feature Request - Make it work with EnumerableQuery
Being able to use EnumerableQuery, instead of a DbQuery / ObjectQuery, would make Unit Testing much much easier for me.
Let's say I have the following piece of code:
public void PriceRange(IQueryable<Product> products)
{
int maxPrice = products.Max(x => x.Prices);
int minPrice = products.Min(x => x.Prices);
return maxPrice - minPrice;
}
When running that code, I would call this method using:
var ctx = new EntitiesContext();
var priceRange = PriceRange(ctx.Products);
When unit testing it, I would call this method using:
var products = new List<Product>
{
new Product { Price = 10 },
new Product { Price = 15 }
};
var priceRange = PriceRange(products.AsQueryable());
Assert.IsEqual(5, priceRange);
But, if I decide to use a FutureQuery, like this:
public void PriceRange(IQueryable<Product> products)
{
var futureMaxPrice = products.DeferredMax(x => x.Prices).FutureValue<int>();
var futureMinPrice = products.DeferredMin(x => x.Prices).FutureValue<int>();
var maxPrice = futureMaxPrice.Value;
var minPrice = futureMinPrice.Value;
return maxPrice - minPrice;
}
Then I'm not able to Unit Test it anymore because IQueryable<Product> will be an EnumerableQuery and that's not supported.
Hello @mmoroni ,
Thank you for reporting.
As I understand the purpose of this request, there is currently no plan to make it compatible with IEnumerable.
If you want to use our library for testing purpose without a database, try to use some library such as: http://entityframework-effort.net/
Best Regards,
Jonathan