I want to test ASP.NET application using NUnit, but it seems WebConfigurationManager.ConnectionStrings collection is empty when running from NUnit GUI.
Could you tell me how to initialize this collection (probably in [SetUp] function of [TestFixture])? Should I copy Web.config somethere?
Thank you!
If you have your unit-test assembly named Company.Component.Tests.dll, then just make sure that Company.Component.Tests.dll.config is there with the proper connection string.
Additionally, it might be a good idea to decouple your connection provider class from the configuration, so that you will have flexibility in persistence (i.e.: switching from *.config to something else) and easier testing.
Also check out ‘How NUnit Finds Config Files‘