Reading Hanselman’s latest, still trying to work out whether I actually like fluent interfaces. The MBUnit example is particularly ugly, to my eyes: testObject.ShouldBeTheSameObjectAs(targetObject).And.ShouldBeEqualTo(testObject).And.ShouldSatisfy(x => x is Object);
Recently I've been noodling about with writing a unit testing library in JavaScript (what's wrong with jsUnit? Nothing, obviously. Doesn't stop me noodling about.). I ended up with some experimental syntax like this:
// function to test
function add(a, b)
{ return a + b;
}
// tests
with (add)
{ ResultOf(0, 0).Is(0, '0 + 0 = 0'); ResultOf(2, 2).Is(4, '2 + 2 = 4'); ResultOf(-3, 4).Is(1, '-3 + 4 = 1');
}
Which is quite nice, but then...