I'm looking for as comprehensive as possible of a mock replacement and wrapper for the ASP.NET HttpContext
in my applications. A comprehensive mock replacement could potentially increase the testability of my ASP.NET web applications substantially, without necessitating migrating every application to more-testable frameworks such as MVC.
Some of the features I am most interested in seeing in an HttpContext
wrapper and mock framework include:
- Serialized session storage (e.g.,
.Session
). - Serialized application-scoped storage (e.g.,
.Application
). - Per-request item storage (e.g.,
.Items
). - HttpRequest data, such as referrers, request Uri, server variables, post data, etc.
- HttpResponse data, such as status codes and content.
- Local file resolution (e.g.
Server.MapPath
) - VirtualPathUtility for application-relative URL path resolution, which has a dependency on the ASP.NET runtime.
- The identity and principal (e.g.,
.User
) for validating authentication/authorization rules. - The
AllErrors
collection for testing error resolution inHttpModule
s andGlobal.asax
.
I considered writing my own interface, wrapper, and mock; however, I believe such must already exist. The variety of mock frameworks is a little overwhelming for a first-timer to absorb.
What is the most comprehensive HttpContext
wrapper and mock that you would recommend?