开发者

Use VirtualPathUtility.ToAbsolute in unit test?

开发者 https://www.devze.com 2023-04-03 19:28 出处:网络
I get the following exception when I use VirtualPathUtility.ToAbsolute(virtualUrl) in a unit test : System.Web.HttpException : The application relative virtual p开发者_StackOverflow社区ath \'~/page/my

I get the following exception when I use VirtualPathUtility.ToAbsolute(virtualUrl) in a unit test : System.Web.HttpException : The application relative virtual p开发者_StackOverflow社区ath '~/page/myaction' cannot be made absolute, because the path to the application is not known.

How can I solve this?


It would be best to break the dependency on it by wrapping it up in another class (using an interface). Then, in your unit test you can mock your class via it's interface.

I'm just doing exactly that!

0

精彩评论

暂无评论...
验证码 换一张
取 消