How do you unit test HTML.ActionLink
I would like to be able to unit test that an HTML.ActionLink or Url.Action will return the correct url based on my route. What is th开发者_C百科e best way to achieve this.
What you should do, is to test your routes. The ActionLink
method and its friends all use the routing engine to build the URLs, so if the routing is ok, the links will be ok.
Here is a short article on that topic:
- Testing URL Generation on Routes in MVC Framework
精彩评论