Hi, we know of a limited solution for this problem.
Say you have a query like this:
IQueryable<Course> courseQuery =
from c in myLearningEntities.Courses
where c.CourseId == courseId
select c;
where Courses is an ObjectSet<Course>.
So you could fake the myLearnningEntites.Courses with a code that looks kind of like this:
var fakeEntities = Isolate.Fake.Instance<MyLearningEntities>();
Isolate.Swap.NextInstance<MyLearningEntities>().With(fakeEntities);
var listOfCourses = new List<Course>();
var returnedCourse = new Course { CourseName = "NEO", CourseType = "Instructor-Led", IsMandatoryForEB = false };
listOfCourses.Add(returnedCourse);
Isolate.WhenCalled(() => fakeEntities.Courses).WillReturnCollectionValuesOf(listOfCourses.AsQueryable());
However, if you would try to use methods specific to ObjectSet and not to List, for example if you have a query like this:
IQueryable<Course> courseQuery =
from c in myLearningEntities.Courses.Include("CourseType")
where c.CourseId == courseId
select c;
Then the above test code would not work. You could write an exact WhenCalled chain on the whole lamda expression like so:
Isolate.WhenCalled(() => fakeEntities.Courses.Include("CourseType")).WillReturnCollectionValuesOf(listOfCourses.AsQueryable());
Does this apply to your case?