mercredi 27 avril 2016

Unit testing in a legacy ASP.NET application to mock HttpContext

I have a method:

public DataSet someMethod()
{
    List a = someObj.getList(name, integerId);
}

Now the integerId is obtained through the HttpContext.Current.Session variable. I have written a unit test for the method. But since, the test runs outside of the web process, HttpContext.Current.Session returns null and the test fails.

Is there any workaround for this?

Aucun commentaire:

Enregistrer un commentaire