1

Does anyone know why is it not possible to get the virtualpath when you are running the asp.net mvc unit test project? Is it because it creates a Temp folders under TestResults Folder.??

kurozakura
  • 2,339
  • 8
  • 28
  • 41

1 Answers1

1

Where would it come from with no web server running?

You have to mock anything related to paths in your mock HttpContext, e.g.:

request.Expect(req => req.AppRelativeCurrentExecutionFilePath).Returns("~/");
response.Expect(res => res.ApplyAppPathModifier(It.IsAny<string>()))
     .Returns((string virtualPath) => virtualPath);
Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273
  • Well the thing is when testing the controller ,from the controller i get some of the values from the global resources and i get an error "The application relative virtual path '~/' is not allowed". Is there any way to resolve this, other than having the global and local resources separated from the mvc project. – kurozakura Sep 05 '09 at 14:41