huysentruitw / entity-framework-core-mock

Easy Mock wrapper for mocking EFCore5 DbContext and DbSet using Moq or NSubstitute
MIT License
132 stars 24 forks source link

Question: Does the DbSetMock support calls to .Include() and .ThenInclude() where lambdas are used? #49

Closed stephajn closed 2 years ago

stephajn commented 2 years ago

We are using this library to mock a DbSet, but on our DbSet, we are making use of .Include(x => x.SomeProperty) and .ThenInclude(x => x.SomeChildPropertyOfSomeProperty)

Some of our tests are failing and I just want to confirm that it isn't because this library isn't able to support code that does that.

Cheers!

Lagyu commented 2 years ago

+1 for this. With .Include(x => x.SomeProperty) eager loading, it seems the mock is not working correctly. (Entities are not loaded to the parent entity and the property returns empty HashSet.)

I'm curious that no one has discussed about the problem up until today. Does this problem only happen in recent EF Core version?

I'm using Microsoft.EntityFrameworkCore 6.0.3 with .Net 6.0.

huysentruitw commented 2 years ago

This library does not support that at this moment. If you can add a test-case and implementation in a PR, I'd happily review and accept it.