Does MVC Contrib fulfill its promise of increasing productivity in ASP.NET MVC
Asked Answered
C

1

10

I am knee deep in starting a new ASP.NET MVC project. Several tutorials have recommended the use of MVC Contrib. I wanted to get the opinion of the Stack Overflow community if it fulfilled its promise of increasing productivity with ASP.NET MVC. Basically are the benefits of MVC Contrib worth adding another leaky abstraction to my application?

Coax answered 17/9, 2009 at 16:0 Comment(1)
You only have to use as much as you want to use. Most of the MVC Contrib ideas have already been incorporated into MVC v2, and we've found it essential on our project (particularly the test helpers).Pergrim
B
10

I think MVC Contrib is invaluable when it comes to testing. They provide a lot of extension methods that allow you to fluently test routing and action results. For example:

"~/Administration/Users/Modify/testuser" .ShouldMapTo(a => a.Modify("testuser"));

...for routing, and for action results:

Controller.List() .AssertViewRendered() .WithViewData>() .Count .ShouldEqual(4, "Should be 4 users returned");

Also MVC Contrib provides a helpful TestControllerBuilder class which can build up a controller and take care of faking all the necessary HTTP context type of things. This doesn't seem like much but paired with DI, writing it yourself if a pain.

        Builder = new TestControllerBuilder();
        Builder.CreateController<CT>();

Moving on from testing, the controller factories for DI/IoC are really useful so you don't have to write it yourself, but not essential IMHO.

The other thing I like about MVC Contrib are the fluent HTML helpers. I think it is much nicer to set HTML properties and other data using these kind of fluent helpers -- here's are two examples:

<%= this.TextBox("name").Label("Activity Category Name: ").MaxLength(50).Class("required")

Beichner answered 17/9, 2009 at 16:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.