This is a mirror of official site: http://jasper-net.blogspot.com/

Unit Testing ASP.NET MVC Routes

| Sunday, January 30, 2011
Two things I always encourage customers to do are;
  1. Always delete the default route pattern after a File –> New project. This helps you focus on designing your routes throughout your site, and helps reduce SEO-unfriendly routes etc.
  2. Always unit test your routing table.
For number two, this is because it is so easy to have a route that looks like this;

/products/{productname}/{action}

… and then a developer comes along and adds a new route higher up the routing table that looks like this;

/products/{category}/{subcategory}

Hey presto, your website is broken. No-one can navigate to the {productname} pattern (assuming you have no other route validation going on). For this reason it is essential to unit test your routing table for any website, especially if it’s already live and you’re modifying it and adding functionality over time, because you could easily take down a whole piece of functionality. Remember to apply all the routes from every Area in your application during testing.

Read more: Simon Ince's Blog

Posted via email from Jasper-net

0 comments: