I'm trying to add unit tests to my MVC application. Specifically, I'm currently trying to test parts of a Web API controller.
When my test method attempts to actually the load the controller, I got an error that indicated I had not defined the required database connection strings.
Even though the connection string are defined in my main project, I understand I needed to add them to my test project's app.config, which I did. But then I got a new error.
VegaModel.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file.
I don't get this error, but the suggested fix seemed easy enough and I copied the <entityFramework> section from my web.config to my test project's app.config.
And now I get this error:
Unrecognized configuration section entityFramework. (C:\Users\Jonathan\Documents\Viper\Branches\Vega\Vega.Tests\bin\Debug\Vega.Tests.dll.config line 38)
Well, okay, those last two errors seems to contradict each other. But more importantly, my main program uses Entity Framework but my test project does not (yet anyway). So I'm troubled about this path that seems to lead towards getting more and more of Entity Framework configured in my test project.
What is the minimalist approach to being able to load a controller that uses Entity Framework from a unit test project?
dbContext, which is part of it's own project. I am referencing that project from my test project. This seems like the best way for me. But the app uses other stuff. There are message filters that perform authentication. I either have to pull in all that stuff, or maybe it's just easy to create a separate application that makes the API calls and test it that way.