The business layer of an application should generally access the database through an abstraction such as a service, command or query class. This has two benefits:
- It expresses our intent whilst hiding the details of the database schema and implementation.
- We can mock the service / command / query in order to write unit tests for the business logic: "If the query returns x, then y should happen."
So far, so good. But how should we test-drive the development of the service class?