AnthonySteele / MvcRouteTester

A library for unit testing ASP MVC route tables for both Web and API Routes
Apache License 2.0
105 stars 43 forks source link

Idea for fixing Issue #37. #39

Closed stevenkuhn closed 10 years ago

stevenkuhn commented 10 years ago

Please DO NOT merge. This is only an idea on how to fix the issue. It does NOT compile.

I spent some time digging through the ASP.NET MVC codebase. I noticed that the DefaultControllerFactory made calls to an extension method called HasDirectRouteMatch() and I thought that could be used to find the correct RouteData. Unfortunately GetDirectRouteMatches() still returns multiple RouteData instances, but perhaps you could iterate over each of those instances and call VerifyExpectations()? If one of them comes back without any errors, then that would be the correct route.

The DirectRouteExtensions.cs file is a file I took from the ASP.NET MVC codebase, but with modifications.

I don't know if this is the correct approach, but I did verify that the Verifier class did work against the route GET ~/VerbedAttr but then failed (which was expected) against the route POST ~/VerbedAttr.

stevenkuhn commented 10 years ago

This pull request is regarding issue #37.

stevenkuhn commented 10 years ago

Closing this since issue #37 is solved by pull request #40.