I'd like to unit test some controller actions and ultimately test that validation attributes and action response filters are functioning properly. To do this sort of thing in ASP .NET MVC was easy with mvccontrib; however, with Web API, mocking the HttpContext seems to be quite a bit different.
How do I go about mocking HttpContext for a Web API controller so that I can test model binding and the like?
You shouldn't need HttpContext in a Web API. Everything you need should be in the HttpRequestMessage and its Properties collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With