Monday, May 20, 2013

App.Config in MSTest

From my experience the easiest thing to do is programmatically load an app.config from a known location. 

Add an app.config for your test project, and populate it as required, then add the following code to the ClassInitialize method on any test class that requires the app.config.

            var map = new ExeConfigurationFileMap();
            map.ExeConfigFilename = @"C:\Development\Tests\WcfUtilities\ClientApplication\App.config";
            Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

No comments:

Post a Comment