Reputation: 7292
I have an MVC3 web application with a local database under App_Data/ASPNETDB.MDF. I also have an integration test project that I'm using to run NUnit against. It has some tests reading from the database. I copied the connection string from the MVC project's web.config to the test project's app.config. Both projects use Entity Framework Code First.
My site runs great. My tests run great. But the data is different in both projects. Ergo ... they're using different databases, right?
<head scratch="true">
<puzzledLook />
</head>
My questions
Upvotes: 0
Views: 187
Reputation: 31
I think that the answer above is about right although I would use Environment.GetCommandLineArgs()[0]
An example for my test project would be c:\program files\microsoft visual studio 9.0\common7\ide\
I seem to recall that the AppData folder is copied to the location of the exe so that it can find the data when it is running
The issue is caused because the unit tests are run by a separate executable called VSTestHost.exe
Upvotes: 0
Reputation: 2548
Test run creates a test folder. Is your database file marked to copy to output directory? In that case could you not add
Assembly.GetExecutingAssembly().Location
to any of your unit tests?
Upvotes: 1