DEV Community

Discussion on: Writing unit tests for EF Core

Collapse
 
dcarapic profile image
Dalibor Čarapić

I usually perform tests by switching to EF in-memory database during the tests. AFAIK this would ensure better testing as the behavior of the DbContext with in-memory database is more 'similar' to DbContext with your standard database.
Are there any benefits / drawbacks in using Moq vs EF in-memory database?

Collapse
 
fluffynuts profile image
Davyd McColl

Both will suffer from the edge-cases where in-memory works fine but the translation from your linq to server-side sql fails - I recommend using a temporary database with the same engine you're targeting. See my post above.