Testing the ASP.NET Web API Controller

I would like the unit test to perform some actions on the controller and ultimately verify that the validation attributes and response filters work properly. It was easy to do this in ASP.NET MVC using mvccontrib; however, using the Web API, the mockery of the HttpContext seems completely different.

How can I trick the HttpContext for the web API controller so that I can check the model binding, etc.?

+5
source share
1 answer

You do not need an HttpContext in the web API. All you need to be in HttpRequestMessage and its property collection.

+2
source

All Articles