HttpContext: Don't Mock

In the past I've done work mocking HttpContext (look here, here, and here). But after reading articles like this and this, I'm convinced that mocking HttpContext is usually not worth the pain and effort. Rather, change your code that uses HttpContext and its' properties to using an object that contains HttpContext. That makes your code easier to test because now you can pull lots of UI code into workflows and models and controllers and have tests around them.

* Posted at 10.16.2007 07:52:28 AM CST | Link *

Blog History