mercredi 6 mai 2015

System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath is null for unit tests

I have this piece of code in my Product code.

string cwd = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
Directory.SetCurrentDirectory(cwd);

When i try to execute this logic in UnitTest i get NullReferenceException since cwd is null.

Can someone help me on what changes should i make to my product code so that it is unit testable?

Aucun commentaire:

Enregistrer un commentaire