Trick: Incorporating Configuration Files into NUnit
One area that was difficult to figure out relative to NUnit was how to use external configuration files. Normally, you can define a Web.config file for ASP.NET Web applications and application .config files for executables. What can you do when NUnit requires a .DLL assembly and your code has been written to use a configuration file, however? The answer is to create a configuration file for testing.
Recall that NUnit creates an instance of the AppDomain for the .DLL you are testing. One of the other things it does is to manually look for an assembly.dll.config file. Thus, if you need configuration options for your application, copy those settings into a .config file for testing. In our example, such a .config file would be MyMath.dll.config, placed in the same directory as the test DLL loaded by NUnit.
To learn more about AppDomains, assemblies, Reflection, and configuration files, pick up a copy of my new book The Visual Basic .NET Developer's Book from Addison-Wesley (available Spring 2003, ISBN: 0672324075).