Umbraco, ASP.NET MVC/MVP, Unit Testing and Version 5.0

So – it’s the return of the Umbraco, and quite a bit has changed since I last spent time with this lovely beast – but it looks like a lot more is about to change.
Since I last worked with this I’ve been working on a couple of ASP.NET MVC projects, which really is great – and like most everyone else I am of course now going around saying how I “cannot believe!” that we all managed to put up with “classic ASP.NET” for so long… bit like we all felt about “classic ASP” a few years back.

So coming back to Umbraco with my new shiny MVC hat on, I of course straight off starting speculating how I could do unit testing and IoC stuff on here.
Turns out Aaron Powell is your main man on this. He’s cooked up a very nice solution where he combines the ASP.NET MVP project with his own (or Farm Codes own) Linq to Umbraco project, and achieves something very close to the stuff we have with ASP.NET MVC. Views (presenters) and Controllers and he is even able to unit test his Umbraco dependent controllers without a HttpContext by using Linq to Umbraco.

The one small fly in the ointment (don’t you hate it when there’s a fly in your favourite ointment?), is that Umbraco 5.0 is going to be based on ASP.NET MVC, and so, one assumes, will have full support for developing MVC .NET macros (almost wrote usercontrols there).
This kind of leaves you with a hard choice for a 4.5/4.6 solution.
Frameworks like ASP.NET MVP, admirable as they are, are almost certainly going to die away in favour of ASP.NET MVC. I can’t see anyone choosing this over the official MVC framework for a new project, and as MVC can also co-exist with classic ASP.NET, it’s very difficult to see any real future for such a project.
It even seems the devs themselves agree, last update on their codeplex site is more than 6 months old at the time of writing, and what’s available is a 0.9 version.
So of course you have to ask yourself, is this the best foundation for my new project?

For enterprise projects this becomes even more relevant, if you start plugging ASP.NET MVP and Linq2Umbraco into your project – you are pretty much on your own, any dedicated Umbraco support can’t be expected to answer or solve problems that might be related to this.

Seems to me, the best approach right now, is to accept that for the time being Umbraco is a classic ASP.NET framework. So do your unit testing on your business layer, and then (if u get the time) do integration tesing with WhatIn or Selenium – and then wait around for brilliant people like Mr. Aaron Powell (who I believe is on the Umbraco core team) to get all the good stuff into version 5.0 – and use this for your next project.
Most likely you would also be able to upgrade from 4.x to 5, and start adding MVC code into your solutiuon at that point – if you’re really, really desperate to use MVC.

I think the overall issue here is also the slightly geeky “must have the latest gadget/tool/framework” mindset – I’m not questioning that ASP.NET MVC is the future, but ASP.NET 4.0 is not just something to be completely ignored, it’s still the flagship (even though all the hot chicks are over on the MVC Cruiser drinking mojitos) and will remain so for the time being.
Before ASP.NET MVC, there was of course a load of ALT.NET writing about how to keep the ASPX/ASCX layer as thin and stupid (that’s how I like my UI) as possible, which mainly means you should have extremely simple event handlers as a rule of thumb (if/else), delegating all the heavy lifting into reusable and testable business/service classes. Also there is nothing stopping us from adding IoC containers to classic ASP.NET, and setting up the business layer as a series of testable services.

There – I feel much better now. Who needs ASP.NET MVC anyway… :0)


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: