Dapper is a micro-ORM library which is very simple and super fast. Quite often the data access code is difficult to be unit tested. In this post, I present some ideas of testing Dapper-based database access.
We use constructor dependency injection throughout our application. Most service classes have constructors, which accept all dependencies in form of interfaces. We also use TDD, which means we must write unit tests for every aspect of our code. So I want to discuss one specific aspect: guarding the constructor parameters from null values and testing this guard.