NUnit and App.config
I try test my Entity class, but i always get a Failure:
System.Data.MetadataException
: Unable to load the specified metadata resource.
I think the pr开发者_如何学JAVAoblem is in connection string and App.config
. I try a lot of stuff: add something to build events, changing config name, copy the config file into solution folder, project folder, project_folder/bin/debug, again change a lot of names... but it still doesn't work.
I have a "AppProject" solution containing 3 projects:
- "Entity"
- "WebTest"
- "MVCApp"
The Entity project has a .edmx
file, and simple POCO classes. When I add the connection string from the Entity/App.config
into MVCApp/Web.config
, the "MVCApp" and database works fine.
When I copy the Entity/App.config
into WebTest/App.config
it doesn't work. I don't know where the problem is.
I use a Visual NUnit, but when I try turn on in NUnit still doesn't work.
My App.config
:
<connectionStrings>
<add name="UserDB"
connectionString="metadata=res://*/Model.Entity.csdl|
res://*/Model.Entity.ssdl|
res://*/Model.Entity.msl;
provider=System.Data.SqlClient;
provider connection string=
"Data Source=.\SQLExpress;
Initial Catalog=TestDB;
Integrated Security=True;
MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
<!-- NOTE: line breaks in the above connection string have been inserted only
for better legibility. -->
</connectionStrings>
See my answer nunit and configs You need to tell nunit what the name of the config file is. it looks for namespace.config by default it seams
Run the webtest see what processor runs in task manager. Mine was QTAgent32_40, go to the configuration file usually under C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE. Look for the config file named "QTAgent32_40.exe.config". edit it with notepad and copy paste your connection string into there. That did the trick for me.
精彩评论