Web Unit Tests Without HttpContext

Phil Haack created a very useful HttpSimulator to assist in unit testing code that accesses the HttpContext.
I was up an running in a few minutes. Here’s a sample that worked for me.

[TestMethod]
public void GetGroupsTest()
{
using (HttpSimulator sim = new HttpSimulator().SimulateRequest())
{
Dictionary<string, GroupDao> groups = GroupCao.GetGroups();
}
}
Share