开发者

How do you unit test HTML.ActionLink

开发者 https://www.devze.com 2022-12-20 10:35 出处:网络
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 tes

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
0

精彩评论

暂无评论...
验证码 换一张
取 消