0

I am using nunit in my application. I want to access config file situated in my test project. I created a fake context via this:

  HttpContext.Current = new HttpContext(
               new HttpRequest(null, "http://tempuri.org", null),
               new HttpResponse(null));

I can't access the config file by any of these:

System.Web.Hosting.HostingEnvironment.MapPath("~/MyConfig.config")
HttpContext.Current.Server.MapPath.MapPath("~/MyConfig.config")
System.Web.HttpServerUtility.MapPath("~/MyConfig.config")
Rocky Singh
  • 15,128
  • 29
  • 99
  • 146

1 Answers1

0

you config files do not get deployed to your Unit Tests. There is an attribute that you can add to your tests called [DeployableItem] and it will point to your config.

What does `DeploymentItem` attribute mean?

Xml file not copying to test output directory

DeploymentItem not deploying files

Community
  • 1
  • 1
phillip
  • 2,618
  • 19
  • 22