Business Module needs web.config data for UnitTest

Topics: Web Client Software Factory
May 30, 2008 at 4:46 PM
We are developing an application very much like the OrderManagementRI. I've even gone as far as setting up our unit testing like Order Management (VSTS). I need to unit test a Repository Service method that needs to pull a value from web.config but when I run the Unit Test it doesn't have access to web.config. How can I unit test modules that need web.config data? 
May 30, 2008 at 5:14 PM
I figured it out. Add an app.config file to the test project... go figure. Hope this helps someone else.
Coordinator
May 30, 2008 at 5:15 PM
This is a common problem.  Your unit tests run in a different context than the web application, and have different configuration files. 
If you take a look at the Orders.Tests project in the OrderManagementRI, we had to deal with this problem, too.  We added an App.Config for the test dll, put the necessary configuration in it, and used it instead of Web.Config.
You should be able to do the same thing.

Michael Puleio -- patterns & practices
http://blogs.msdn.com/mpuleio