I've just started to work with NUnit in order to provide some test coverage for my projects.
Within my main library.dll I need to load up configuration data from an external file that goes with the library, library.xml.
This works fine when I'm using the library, because I use the following to get the directory in which to look for the config file:
string settingspath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
The problem I've noticed is that when I'm unit testing with NUnit, it copies my assemblies to a Shadow Copy, but doesn't take any of the other files with it, so of course my init fails due to missing config files.
Should I be doing something different to locate config files from within my library? (it's a server app, and I don't want to use the standard app settings, or user's local settings, etc)
Encountered the same problem ... following is my workout:
Before the SUT run, update AppDomain's Base Directory in this way....
Use can use
TestContext.CurrentContext.TestDirectory
as mentioned by Charlie Poole from NUnit here: