For a while now I’ve been trying to figure out a good way of using unit testing to validate more of my code with ASP.NET applications.

Most of our applications correspond to the n-tier model with the data-layer and business objects separated from the presentation layer.

I’m still trying to find a good solution, but I think that some of these new ideas might help once I get my head around all the concepts.

Mock objects seem like they can play a part, especially when you want to test something in isolation from the other layers (eg. testing the code that calls the data layer, without actually depending on the data layer to be all correct and available). Rhino Mocks is the mock object framework I’m trying out at the moment.

Inversion of Control is another concept that seems to help with this by removing direct dependencies between classes. Josh has some thoughts on this while using the Castle Project’s Windsor Container

Finally, the Model-View-Presenter design pattern might be a way of hooking this all up together. Billy McCafferty outlines his ASP.NET architecture and also has published an artile on using MVP with ASP.NET. Phil Haack also illustrates using the Supervising Controller pattern (an update on the MVP pattern) with ASP.NET.

Then again, I could have it all mixed up, but I do think some of these techniques are going to be valuable tools - a pity that the learning curve is reasonably steep at the moment.