C
C#2y ago
nauvran

✅ testing EF CRUD functions

Is it worth trying to do? And if so should I mock the database and use unit tests or should i make integration tests? Most of the calls are fairly simple with a few relationships, there is however at least one function with a more complicated relationship between 6 tables where parts have to be converted to a viewmodel
10 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
nauvran
nauvranOP2y ago
I'd end up with a lot of those though And wouldn't I need seperate test database
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
nauvran
nauvranOP2y ago
Not sure I can, need to talk to my senior dev colleague about the servers Anyway thanks for the help
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
toddlahakbar
toddlahakbar2y ago
My question is why are you unit testing or thinking you need to unit test the database? Unit tests are for business logic
nauvran
nauvranOP2y ago
Database is like 500 tables I'm not sure how else to test my different actions without having the testers do all the work
toddlahakbar
toddlahakbar2y ago
But is there business logic in the database? If so, why? If not, why does the database matter for unit tests. If business logic is properly isolated, there should be no need for the db to test it
nauvran
nauvranOP2y ago
Yeah there are some triggers, sadly So you're suggesting just skipping testing CRUD? Mhm so just extract all the logic that actually does things with the objects and just test on that and ignore the EF on the database
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server