I am writing an HttpModule in C#, and have written a number of unit tests to test the code.
The module is pretty simple, all it does is that it inspects a number of cookies, and expires the ones that need to be expired based on our business logic.
But I want to make sure that this does not break anything. So I want to test it good and thorough!
I have read the articles on using System.Web.Abstractions for mocking the request and response objects. This is great, and works! For more info look at: http://www.kongsli.net/nblog/2009/05/03/aspnet-35-improving-testability-with-systemwebabstractions/
But I would like to know if there is something I really need to test when it comes to writing HttpModules. Something that isn't directly related to my business logic code. Something to test that I dispose the Module correctly for example, or something else that could potentially break.
Thanks, JP
Easy:
IHttpModule
implementation.Example:
void InYourHttpModule()
{
myLogic.Invoke(Request.Cookies, Response.Cookies);
}
In that way it's very easy to validate that your logic do what it says and nothing else.