Reputation: 16430
I have a Appsettings type initializer in my main project, which gets strings from appSettings in my web.config file. This appSettings section and my connectionStrings section use attributes like configSource, file to reference values.
It all works, except for when my unit testing project tries to test it.
An error is thrown in the type appSettings type initializer, that the appSettings/connectionStrings values in web.config aren't defined.
How can I get my Applicaton to intiailize properly so the web.config is accessible? Do I need to initialize an instance my main project ( the MVCApplication )?
It's causing Entity framework to have no connection string also, cause value not set in web.config
Upvotes: 0
Views: 642
Reputation: 6992
I suggest adding an App.config to your Unit test project and reference your /Configs/AppSettings.local.config within your app.config.
<configuration>
<appSettings file='/Configs/AppSettings.local.config' />
</configuration>
Upvotes: 1