-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Include #15
Comments
Would love to hear more about this, I also need this feature :) |
Are you able to help me with development? Last time I have limited time to support my all projects that is why this feature is parked a bit. |
Let's assume EF code like this:
Then Include mock should work like this:
Have you tried this solution? |
@MichalJankowskii When I run similar code, I get the following error:
But more important, how do I verify with above code that my SUT implementation actually contains an Take for example above method public IEnumerable<Person> GetPersons()
{
- return this.personContext.Persons.Include("Address").ToList();
+ return this.personContext.Persons.ToList();
} That's because the test expected db result already contains the "navigation" part ( Similar issue: romantitov/MockQueryable#45 |
This is a great question. Provided example worked fine in 2020. From that time, Microsoft changed the implementation of EF library. The latest implementation uses extension methods for the Include function. And it is not possible to use Moq to fake it. This is the limitation of EFCore architecture and Moq features. I am not able to support this in this lib. You could create your own extensions and wrap those from EF. Here you could mock that based on your implementation. But this is not the approach I would like to have in the code. |
Hi @MichalJankowskii , Sorry for re-opening this, but I felt like it's better than opening yet another issue for this. First of all thank you for your efforts put into this little library, looks very promising. While I understand that implementing the full proper Include functionality is difficoult to say the least, but I'd also like to at least validate the added includes in my unit tests. I see that in the current EFCore there is not too much change to catch these calls, as the code checks whether the provider is an instance of Thank you |
As an addition, I see that this Update: I've just realized that it's technically part of the public API but it's in the |
I used ReturnsDbSet to mock the data. But it does not support include clause.
What is the syntax to support include?
The text was updated successfully, but these errors were encountered: