I am developing an MVC3 application in C#.
The application has several projects. Since I want to test the behavior of the Repository, the relevant projects are the Repository project itself and the Unit Test project.
I am facing an issue in testing phase, since everytime I run a test it launches an exception
Test method UnitTest1.Repository_IsNotNull threw exception:
System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
I already encountered this exception other times and the only thing I had to do was copying the ConnectionString from the referenced project web/app/.config file (this case the Repository) to the referencing one (in this case the UnitTest).
The problem in this case is that UnitTest project does not have neither an app.config nor a web.config file.
What can be the cause of this issue and how to fix it?
You just add an app config file to the unit test project. Add -> New Item -> General -> Application Configuration File.
You don’t mention which test framework you use, but this works fine with MSTest.