6.4. Summary

We have done such a good job abstracting each layer that we won't have to make any changes to the controller. The following MessageController constructors will work as is:

public MessageController()
    : this(null)
{
}

public MessageController(IMessageService service)
{
    Service = service ?? new InMemoryMessageService();
}

We were also able to use the IRepository pattern and abstract the persistence mechanism from the business logic. That allowed us to create an in-memory database implementation that is used relatively easily during testing but can easily be replaced with a SQL-backed implementation. In the coming chapters, you will see the benefits of this design and how much it simplifies our testing and maintenance.

Get ASP.NET MVC 1.0 Test Driven Development: Problem - Design - Solution now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.