Does this only work with MVC 3

Jan 11, 2012 at 5:50 PM

I'm using MVC 2.0 and am getting the error that it needs System.Web.Mvc. Am I out of luck here?



Jan 11, 2012 at 7:07 PM

No , not at all. Just add a reference to System.Web.Mvc to your test project.

Jan 11, 2012 at 7:16 PM

I did however it is looking for System.Web.Mvc version 3.0

Jan 11, 2012 at 7:18 PM

Here is the exact error:


Test method IntranetMVC.Tests.AreaRouteTests.TestIncomingRoutes threw exception: 
System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
at MvcRouteUnitTester.RouteTester`1..ctor()
at IntranetMVC.Tests.AreaRouteTests.TestIncomingRoutes() in AreaRouteTests.cs: line 14
Jan 11, 2012 at 7:35 PM

Ugg figured it out. I got bit once again by the "Copy Local" on the dll reference. Once set to true all worked out fine. Thanks

Jan 11, 2012 at 7:40 PM

Let me know how it works on your MVC 2 project.

I have seen a couple of reports about the behavior being different between MVC2 and MVC3 when dealing with optional parameters. I'd love to know if you find that to be the case when testing route entries with UrlParameter.Optional

Jan 11, 2012 at 8:43 PM

Well this is what I've added so far and passes fine.


          tester.WithIncomingRequest("/MyArea/Accounts").ShouldMatchRoute("MyArea", "Accounts", "Index");
          tester.WithIncomingRequest("/MyArea/Accounts/9B1C65D3-EB82-4D8F-9DF1-81F0CAFC7504").ShouldMatchRoute("MyArea", "Accounts", "Index", new { id = "9B1C65D3-EB82-4D8F-9DF1-81F0CAFC7504" });




          tester.WithRouteInfo("MyArea", "Accounts", "Index").ShouldGenerateUrl("/Thumbo/Accounts");
          tester.WithRouteInfo("MyArea", "Accounts", "Index", new { id = "9B1C65D3-EB82-4D8F-9DF1-81F0CAFC7504" }).ShouldGenerateUrl("/MyArea/Accounts/9B1C65D3-EB82-4D8F-9DF1-81F0CAFC7504");

Jan 11, 2012 at 9:01 PM

Cool. I didn't think there would be an issue. :)