开发者

C# Unit Test set HttpRuntime.BinDirectory

I've got a clear and simple question. The webapplication i'm working on is using unit tests (close to 1500 tests). Due to an required modification in the application several tests are failing because The HttpRuntime.BinD开发者_运维问答irectory doesn't have a value and therefor throws and ArgumentNullException.

Is there a way to set my own value in HttpRuntime.BinDirectory? Or to Mock it using the Moq framework?

Any help is appreciated!


Assuming your own code is calling into HttpRuntime.BinDirectory, then just don't do that. Create your own class like ExecutionContext with a property BinDirectory which can infer the correct location based on if it's called from asp.net or inside unit tests.

You could also use Assembly.CodeBase instead which will work in both situations as long as you grab one of your own assemblies (not something in the gac).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜