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

Testing url generation #15

Closed AnthonySteele closed 11 years ago

AnthonySteele commented 11 years ago

Any ideas about feasibility and need for testing the other way around, i.e. instead of testing that a url is mapped to a particular controller method "routes.ShouldMap("/").To(x => x.Index());"

we test that a given controller method generates a url, something like:

routes.Action(x => x.Index()).ShouldMapToUrl("/")

Is this important? Hard?

alexjamesbrown commented 11 years ago

It must be possible, Html.ActionLink does something along these lines...?

AnthonySteele commented 11 years ago

Does it actually add anything important though?

alexjamesbrown commented 11 years ago

Well, it could be nice to be able to test like this... so you're sure the action routes etc... are generated as expected?

AnthonySteele commented 11 years ago

What does it do that the exiting test doesn't?

alexjamesbrown commented 11 years ago

Good point.... Just another fluent way of expressing expected result i guess....

Not essential at all

AnthonySteele commented 11 years ago

We have code for it here: https://github.com/AnthonySteele/MvcRouteTester/pull/18 Specifically it tests that the url generated by Url.Action for a particular controller and action name is as expected, which also tests the route table in a slightly different way.