0

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

2
  • When unit testing, app.config is read by default. Commented Jul 3, 2013 at 5:56
  • My situation is a bit more complicated, it references /Configs/AppSettings.local.config Commented Jul 3, 2013 at 5:58

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.