MbUnit AssertEx
New month, new year, new decade and my first post (well not strictly speaking but I was getting complaints). I'm going to try and start posting more often this year and hopefully get back to posting about MbUnit again (I've even started contributing again, more on that at a later date).
To kick things off I'm going to talk a little about a new feature in MbUnit v3, AssertEx. This assert makes use of lambda expressions to express your test, all you need is an additonal referance to the MbUnit35.dll. So rather than this.
int value = numbers.Add(1,1);
AssertEx.AreEqual(2, value);
I can do this
int value = numbers.Add(1,1);
AssertEx.That(() => value == 2);
I rather like how expressive this is, I could also do this.
int value = numbers.Add(1,1);
AssertEx.That(() => value == 2 && value > 1);
Combine as many expressions for my data as I wish, if you prefer you can break it down.
int value = numbers.Add(1,1);
Assert.Multiple(() =>
{
AssertEx.That(() => value == 2);
AssertEx.That(() => value > 1);
});
I recommend you explore AssertEx more.