I'm trying to do some unit tests that include some Linq to Entities queries.
I've recently added .AsNoTracking()
and possibly .Includes(x => x.table)
to the queries and now they start failing.
I've fixed the .AsNoTracking()
issue by adding A.CallTo(() => db.table.AsNoTracking()).Returns(db.table)
but I can't figure out how to solve the issue I'm having with .Includes()
The current error I'm encountering is the following:
Castle.DynamicProxy.Generators.GeneratorException: Can not create proxy for type System.Data.Entity.Internal.Linq.IInternalQuery`1[[DataClasses.INVOICE.table
because it is not accessible. Make it public, or internal and mark your assembly with...
EDIT / FIXED: I can solve most of my issues with this by mocking away the getter so that FakeItEasy and AutoFac don't need to worry about the queries I wrote. If I want to test a specific query I'm going to opt for using SQLite instead