A Friendlier NUnit PredicateConstraint

I've taken to using NUnit's constraint model for my unit tests, as I find it a great way to write readable tests which state exactly what they prove. NUnit has lots of built-in Constraints, but its PredicateConstraint doesn't return very helpful error messages; here's a friendlier version, which does.

Populating ASP.NET MVC ViewModels using ViewModelBuilders

The ViewModels in my current project had got quite complex; as well as properties copied from model objects, they increasingly had flags used by Views to know whether to render links or sub-sections. The logic which set these properties was bloating Controllers, so I factored it out into objects which populate all non-editable properties of a ViewModel; ViewModelBuilders. Here's how :)

An Improved HttpModule to Redirect Requests When an Uploaded File is Too Big

Further to comments on my previous post on this topic, I realised my HttpModule which gives a user a friendly error message if they upload a file which is too big only dealt with half of the problem. The maximum size a request can be is specified in the machine.config and web.config in the maximumRequestLength attribute on the httpRuntime element; if a user uploads a file which is larger than that, the part of the HttpModule which checks the request size is by-passed, and the user gets a not-ver

Interview question - what's wrong with this code?

You can learn a lot about good code from reading bad code, and at least something about how well someone codes from what they can tell you about bad code. With this in mind I handed a print out of some bad code to the latest prospective developers I've interviewed, to see what they made of it. I'll write another blog with the things I think is wrong with the code soon (there's quite a few of them), but it'd be very interesting to hear what people think is wrong with it before I do :)