This section covers the testing of the service layer part implemented previously. As we did in Chapter 8, Building the Data Access Layer, we need to set up a mock catalog context that provides the data necessary for testing the service classes. The Catalog.Infrastructure project already has its own implementation of the TestCatalogContext class and the ModelBuilderExtensions class. Furthermore, we can use the same two classes to implement the tests for the service layer. What we need is just a bit of refactoring and optimization on the Catalog.Infrastructure project.
Testing the service layer
Refactoring testing classes
After implementing the ItemsRepositoryTests type, in Chapter 8, Building the Data Access Layer, you might...