I\'d like to give the background to this question. Skip if you like. For quite a while I\'ve paid close attention to the on going debates on stackoverflow and elsewhere rega
For anyone who stumbles upon this issue with interest on how to solve the .Include("Foo") problem with NSubstitute and Entity Framework 6+, I was able to bypass my Include calls in the following way:
var data = new List()
{
/* Stub data */
}.AsQueryable();
var mockSet = Substitute.For, IQueryable>();
((IQueryable)mockSet).Provider.Returns(data.Provider);
((IQueryable)mockSet).Expression.Returns(data.Expression);
((IQueryable)mockSet).ElementType.Returns(data.ElementType);
((IQueryable)mockSet).GetEnumerator().Returns(data.GetEnumerator());
// The following line bypasses the Include call.
mockSet.Include(Arg.Any()).Returns(mockSet);