mehdime / DbContextScope

A simple and flexible way to manage your Entity Framework DbContext instances
http://mehdi.me/ambient-dbcontext-in-ef6/
MIT License
634 stars 271 forks source link

TDD with DbContextScope #55

Open k2ibegin opened 7 years ago

k2ibegin commented 7 years ago

Hi,

I am wondering how can I implement TDD with DbContextScope. I have seen some of the methods such as Repository pattern and using Effort package. I am a beginner in TDD, so I am struggling with dependencies break down. I looked into couple of SO discussions but using moq framework seems to be an overkill ? ( as unit tests should be simple)

Thanks in advance !

VictorioBerra commented 7 years ago

For unit tests, you will benefit from moq. The whole point of a unit test is to test your isolated business logic. The reason a service layer exists is because it should isolate business logic from your database stuff. As for an integration test, you can just set up your EF connection string to hit a test DB and test away. Moq your interface and instead of saving rollback every transaction.