1

Closed

Add Set* extension methods for all HttpRequestMessage properties

description

For unit testing you often need to setup a full HttpRequestMessage so that conneg can be run in the API controller action. We have Get* extension methods for the properties hanging off of HttpRequestMessage.Properties but we don't hvae Set* methods. We should add the Set* methods.
Closed Jun 16, 2013 at 11:55 PM by eilonlipton
Closing this because we have made unit testing much easier in Web API, as noted in this spec page: https://aspnetwebstack.codeplex.com/wikipage?title=Improving%20ApiController%20testability&referringTitle=Specs

The HttpPropertyKeys are public so people wanting to write tests that depend on the property bag can set them manually.

If there are specific unit testing issues still remaining we should have specific bugs on those.

comments

HenrikN wrote Sep 4, 2012 at 9:16 PM

We should consider making the HttpPropertyKeys internal so that people go through the Getter/Setter instead. That would be much more robust moving forward.

marcind wrote Sep 5, 2012 at 6:25 AM

Making it obsolete might be too much of a breaking change. But we could certainly make mark those properties as obsolete.

marcind wrote Sep 5, 2012 at 6:26 AM

Sorry, meant to say that making it internal would be a breaking change. Obsolete should be fine though.

HongmeiG wrote Mar 19, 2013 at 12:55 AM

I think all the helpers have been added. Please confirm.

HongmeiG wrote Mar 19, 2013 at 12:56 AM

BTW, let us not make those keys internal or obsolete. There is no good reason to break existing app here.