Should I run Unit Tests against my SQLRepository as well?
c#, repository-pattern, tdd, unit-testing
Solution
You should have tests which mock out the repositories (as it looks like you do), that doesn't query the database itself, but return results as if they did. These are the tests for functions that call the repository functions.
But it is also useful and recommended to have tests that check the database itself, and check if they return what they should. They should be also "unit tests", not depending on other stuff. Try not to depend that the database is on a determined state, but instead, make a setup to build your database initial state.They will probably be slower, and may not be run on every commit and build (I mean, don't run if it really takes a lot of time).
Finally, in your integration tests, do all the stuff you should do.
Problem
I'm developing a Domain Model based on the Repository Pattern and all of my Unit Tests as part of TDD are going against a Test Repository. My question is: at what point do I create integration tests against the SQL version of the Repository? My concern is that the code to access data from objects (Test Repository) will work fine. But the database version (SQL Repository) is so different under the covers that my vital code in the SQL Repository will end up not working and be in itself untested. How do I ensure that it's working as intended? Am I missing something about the process? Regards.