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

Support for custom IDirectRouteProvider implementation in unit tests #60

Closed willapp closed 9 years ago

willapp commented 9 years ago

We're currently using this package: https://github.com/Dresel/RouteLocalization to provide localization support for MVC attribute routing. I wanted to be able to add unit-tests to verify the translated routes are added correctly but the current implementation of MvcRouteTester doesn't allow you to supply an implementation of IDirectRouteProvider to the MapAttributeRoutesInAssembly(...) method. As a result the localized routes don't get added so I can't verify them during testing.

To address this I've simply updated the MvcAssemblyReflector to pick an alternative override of System.Web.Mvc.Routing.AttributeRoutingMapper.MapAttributeRoutes which allows supply of an IDirectRouteProvider implementation. Overrides have then been added to WebRouteTestMapper so I can supply an implementation during unit testing.

I think it would be useful to merge this into the main repo and re-issue an updated NuGet package so that others might benefit from the added flexibility.

willapp commented 9 years ago

Just to be clear I'd only like the following commit to be considered for the pull request: https://github.com/willapp/MvcLocalizedRouteTester/commit/c1ce406cf83ca445a07c11e5261be54ebf1cd71b

The further commits were just to allow me to publish a temporary package to NuGet so I can include the modifications in our CI build process.

AnthonySteele commented 9 years ago

I think that I can pull that commit in, but not not merging this whole PR with the different nuspec etc. I will try to get another official nuget package out soon.

willapp commented 9 years ago

Hi Anthony,

Yes sorry as I've said it's only the first commit. I'm still a bit new to Git/GitHub so I didn't realise it would add the extra commits to the PR - I needed a NuGet package to integrate with our CI builds and wasn't sure how quickly you could merge+release so I went ahead and published my own (temporary) package with the change included.

AnthonySteele commented 9 years ago

OK, I have cherry-picked that commit into master