views:

13

answers:

1

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.BinDirectory 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!

+3  A: 

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

Sam
@Sam. Thanks for the quick response! I added an property to return the correct BinDirectory value.
Rob