Geeks With Blogs
Guilherme Cardoso, Blog EN .NET geek

I've decide to write about unit testing in the next weeks.
If we decide to develop with Test-Driven Developement pattern, it's important to not forget the routes.

This article shows how to test routes. I'm importing my routes from my RegisterRoutes method from the Global.asax of Project.Web created by default (in SetUp).
I'm using ShouldMapTp() from MvcContrib:
The controller is specified in the ShouldMapTo() signature, and we use lambda expressions for the action and parameters that are passed to that controller.

        public void Setup()

        public void Should_Route_HomeController()
                .ShouldMapTo<HomeController>(action => action.Index());
        public void Should_Route_EventsController()
                .ShouldMapTo<EventsController>(action => action.Index());
                .ShouldMapTo<EventosController>(action => action.Read(1, "Title")); // In this example,44 is the Id for my Event and "Concert-DevaMatri-22-January" is the title for that Event
        public void teardown()
Posted on Thursday, January 27, 2011 12:32 PM | Back to top

Comments on this post: Testing Routes in ASP.NET MVC with MvcContrib

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Guilherme Cardoso | Powered by: