Couldn't instantiate proxy of class
tiagodenoronha opened this issue · comments
Can I see the DefaultOptions declaration?
It's the same as the readme:
public DbContextOptions DefaultOptions{ get; } = new DbContextOptionsBuilder().Options;
Can you try public DbContextOptions<PlantsContext> DefaultOptions{ get; } = new DbContextOptionsBuilder<PlantsContext>().Options;
?
(DbContextOptions
cannot be casted to DbContextOptions<PlantsContext>
)
You'll need to post more context I'm afraid
I can do you one better, I can give you a sample project.
Try running the test Plants_GetAll_RetunsNull on this branch: https://github.com/tiagodenoronha/PlantsIdentifier/tree/feature/testProject
When changing AsEnumerable()
in the service to ToArray()
, it seems to work, so I'll have to dig into the source, probably something needed for the extension method AsEnumerable()
is just not mapped.
For the test Plants_GetAll_ReturnsOk
, you also need to initialize the DbSet:
dbContextMock.CreateDbSetMock(x => x.Plant);
Hmm gotcha, i'll change the method to ToArray for now :)
The first test I hadn't tried it yet :b
I'll close this issue and open up a new one with "Map AsEnumerable" so you can track it better.