chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
We are using EF4 and creating test cases for DAL layer (DAL layer is having linq query).
We are using TypeMock as mocking framework.
For testing, we are creating Fakecontext of ObjectContext and mocking CreateObjectSet method as follows
Isolate.WhenCalled(() => fakeContext.Context.CreateObjectSet<User>())
.WillReturnCollectionValuesOf(fakeUsers.AsQueryable());

The above is working fine. The issue is when we are trying to include related tables using 'Include'.
We have extended the include method as follows

public static IQueryable<T> Include<T>(this IQueryable<T> source, Expression<Func<T>> property)
{
var objectQuery = source as ObjectQuery<T>;

if (objectQuery != null)
{
var propertyPath = GetPropertyPath(property);
return objectQuery.Include(propertyPath);
}

return source;
}
So what happen is, in the above 'Include' method the source type should be ObjectQuery<T>. But as we have mocked 'CreateObjectSet', source type in 'Include' method is of collection.Generic.List type. Kindly let us know how should we mock in the above case. Your timely help will be highly appreciable. Thanks
asked by sony (7.2k points)

1 Answer

0 votes
Sony,

For the several EF4 questions you posted it seems like we need more context and information. Can you approach us through our support email (support at typemock.com) with the entire batch of questions, along with your customer information, and we will provide you with more in depth support.

Thanks,
answered by doron (17.2k points)
...