I have moved my active blog over to tumblr. I've maintained this blog for reference but will be posting to http://www.robustsoftware.co.uk instead. I've pointed my Feedburner feed to tumblr so if you're subscribed already you should already have switched with me.

ASP.NET MVC Route Testing with HTTP Verbs

I’ve started RESTful ASP.NET MVC from scratch and I am test-driving it. Writing code without tests is ok for proofs of concept but as I was planning on continually adding to the project I felt I had to start again and make sure everything was tested. As part of the process I was looking to test my routing rules. I used Phil Haack’s route testing helper as a starting point but I think I’ve customised it enough to warrant a post.

The first thing I did was change his static method into an extension method. However, my routes were also dependant upon the HTTP verb used so I had to add that in on top. I also needed to check that a route wouldn’t be matched for the same reason as a URI which is valid for a GET may not be valid for a POST.

My route test helper and an example of it in action from the test-driven branch of restful-aspmvc.

Related posts