I need to create some unit test of my code that are working right now with a SQL Server 2005 through a connection configured on “dataconfiguration.config” file and working with Enterprise Library. I can not change this kind of connection code, so I need to configure my test project in order to work with this.
The message error is the following:
Invalid section name. The section ‘dataConfiguration’ does not exist
in the requested configuration file ‘C:\Program Files (x86)\Microsoft
Visual Studio 10.0\Common7\IDE\QTAgent32.exe.Config’ or the file
‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config’.
Make sure that the ‘enterpriseLibrary.configurationSections’
configuration section exists in one of the files and that the section
‘dataConfiguration’ is defined.
Any help with this will be preciated! Thanks
When you run a test project, the code which is running gets its configuration from the test project’s app.config rather than the project under test’s own config file. You’ll need to either copy the configuration into the test project’s config file, or abstract out the way the project under test obtains its configuration and stub that out in your test.
Edit
To create an app.config file, right-click the project in Visual Studio and select Add > New Item. Select ‘General’ under Installed Templates and choose ‘Application Configuration File’. you’ll need to copy the appropriate sections into there for the project under test to find them.