ASP.NET MVC Route Testing with HTTP Verbs
Posted by Garry Shutler in ASP.NET MVC, Extension methods, REST, Unit testing
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
This entry was posted on at Saturday, July 18, 2009 and is filed under ASP.NET MVC, Extension methods, REST, Unit testing. You can follow any responses to this entry through the RSS 2.0. You can leave a response.
