At the Elevate presentation yesterday I learned a lot about C#3/4 by Magnus Lidbom.
But as a side-effect I also picked up a nifty syntax for NUnit assertions. It’s called Constraint-based Assertion Model and has been around since NUnit 2.4. Which shows that I am a slow adopter… Sad.
OK – what’s the deal with it? It gives you a almost fluent interface to assertions. Here is an example on how to do a simple assertion in the old style:
And here is the same assertion in the Constraint-based version:
Now read it out loud; Assert… That … i … is equal to 10. Nice, isn’t it? I like that a lot.