kurozakura
kurozakura

Reputation: 2359

"Virtual Path Not Known" When running ASP.NET MVC Unit Test Project!

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.??

Upvotes: 1

Views: 937

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126587

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);

Upvotes: 1

Related Questions