huysentruitw / entity-framework-core-mock

Easy Mock wrapper for mocking EFCore5 DbContext and DbSet using Moq or NSubstitute

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

stephajn opened this issue · comments

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!

commented

+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.

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.