tags:

views:

223

answers:

0

I'm getting an expected error with my route testing using MvcContrib's ShouldMapTo function. According to the results, everything is fine, but the helper throws an AssertionException with an unfortunately sparse message. I'm using MVC1 and the corresponding MvcContirb.

[Test]
public void ThisShouldNotErrorButItDoes()
{
    "~/District/ParticipantInfo/1907/2010".Route().Values.ToList().ForEach(r => Console.WriteLine(r.Key + ": " + r.Value));
    Console.WriteLine(((Route)"~/District/ParticipantInfo/1907/2010".Route().Route).Url);
    "~/District/ParticipantInfo/1907/2010".ShouldMapTo<DistrictController>(c => c.ParticipantInfo(1907, 2010));
}

The first two lines show that the exception should not be thrown. I'm mapping the correct controller, action, districtNumber, and surveyYear to match the correct route of {controller}/{action}/{districtNumber}/{surveyYear}.

My routes:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Participation",
            "{controller}/{action}/{districtNumber}/{surveyYear}",
            new { controller = "District", action = "ParticipantInfo" });

        routes.MapRoute(
            "Default",                                                          // Route name
            "{controller}/{action}/{id}",                                       // URL with parameters
            new { controller = "Home", action = "Index", id = string.Empty });  // Parameter defaults
    }

The Error I'm getting is MvcContrib.TestHelper.AssertionException : Value for parameter did not match.

I've tracked this down to: public static RouteData ShouldMapTo(this RouteData routeData, Expression> action) where TController : Controller
Which is inside of RouteTestingExtensions.cs

Does anyone have any clue on this one?