lundi 28 mars 2016

Are HttpContext.Current.ApplicationInstance and the sender object in an IHttpModule always the same thing?

In order to facilitate unit testing of components that reference the HttpApplication, we have a class that uses a lambda + proxy wrapper to direct the call to either a mocked HttpApplication or the real HttpApplication (via a proxy class), using HttpContext.Current.ApplicationInstance.

However, we have code in an IHttpModule that is added to our pipeline, and one of the parameters of the event being fired is the Object sender, which is cast to an HttpApplication. In order to mock this appropriately, I would like to use the proxy class that refers to HttpContext.Current.ApplicationInstance rather than the sender parameter on the event. Based on my reading of the request pipeline documentation, I'm not sure how the two would ever be different, but I'm not certain enough to throw that in production and see if it's true. :)

Are they always the same? If not, does anyone have a good suggestion on how to mock references to HttpApplication in an IHttpModule where we are explicitly passed the HttpApplication reference?

Aucun commentaire:

Enregistrer un commentaire