Structuring ASP.NET MVC for Maximum Testability

This article from Keith Burnell presents best practices and techniques to increase the testability of ASP.NET MVC applications. This includes how to structure the solution, architecting the code to handle the injection of dependencies and implementing dependency injection with StructureMap.

The article starts with some best practices for laying out your Visual Studio solution based on experience developing large enterprise ASP.NET MVC applications using test-driven development (TDD). As you cannot get very far unit testing an n-tier application before encountering a dependency in the code under test, the article explains how to introduce dependency injection to the software architecture to create extremely loosely coupled code. The StructureMap DI/IoC framework is then presented as a tool to implement dependency injection. Keith Burnell conclusion is that “by using these practices and techniques in your ASP.NET MVC applications, you’ll position yourself for an easier and cleaner TDD process.”