Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Test Project can't reference MVC project

Perhaps this is easier if you let Visual Studio create the Unit Test project when it creates the MVC project. But seeing as how that wasn't done, how should I add a Unit Test project now?

Here's what I did:

  1. Right-click solution and click Add Project.
  2. Browse to Visual C# > Test and add a Unit Test Project.
  3. Within the Unit Test Project, I click Add Reference and then choose the MVC 5 project.

After all of that, I see a little yellow hazard icon on the newly added reference, and I can't access any of its namespaces in the code.

like image 268
Steve Wortham Avatar asked May 13 '14 18:05

Steve Wortham


1 Answers

I figured it out. I forgot that there will be a warning message that goes along with the little yellow warning icon on a reference. So I went to the Error List and enabled "Warnings" in the filter. There was a message about mismatched .NET versions. The unit test project was using .NET 4.5 and the MVC project was 4.5.1. I changed the unit test project to 4.5.1, and voila, it works.

like image 127
Steve Wortham Avatar answered Oct 10 '22 12:10

Steve Wortham