Mike Bosch's Blog on .NET

Agile enterprise architecture in .NET, SOA, WCF, WS-*, AJAX, MVC, Sharepoint and more...

ASP.NET MVC Tip #6 - Code Snippets for Quickly Testing Routes

Scenario:

You want to write some tests for your route configuration, but you hate typing...

Solution:

We can create some VS Code Snippets to generate most of the tests for you.  While messing around with Kigg, I got the idea to create some snippets to make writing the route tests a little simpler.  These snippets assume you are using MbUnit and Rhino Mocks.  You also need to have your references and imports set up correctly.  With these snippets you can create a full route test fixture with just two commands:

mvcrtestfix - generate the test fixture class for your routes

mvcrtest - generate the test for a specific route

The route test will generate code to check for the correct controller and action.  You can add additional asserts to check that values were passed in.  You can download a zip file with both snippets here.  Then just import them from VS Code Snippet Manager menu item and you'll have access to it in your IDE shortcuts.

 

And here's some of the code it will generate for you with placeholders for you to edit.



Hope this helps.... 

Posted: Feb 21 2008, 07:00 AM by MikeBosch | with 6 comment(s) |
Filed under: ,

Comments

vrouw zoekt man said:

Nice snippets, you may also like:

# July 26, 2010 2:57 AM