Friday, April 27, 2007

Manually creating an HttpRequest for testing

I'm currently writing unit tests for some code that uses the information found in the Headers property of an HttpRequest object. As such, I want to be able to create my own HttpRequest object with the appropriate headers.

This isn't as easy as I'd like it to be, as presumably the intent for the class is that you're handed an instance of it at the appropriate time, rather than putting one together yourself (which is fair enough).

Time to delve into System.Reflection for a bit of hacking:Job done!