I'm build a library inspired by RSpec on top of NUnit 2.5+ in order to improve my tests readability. The source code is available at http://github.com/educobuci/SpecUnit.
This library allows me to write tests like this:
[Test]
public void It_should_returns_0_for_all_gutter_game()
{
var game = new Bowling();
for (int i = 0; i < 10; i++)
game.Hit(0);
game.Score.Should(Be.Equal(0));
}
The "Should" method is an extension method for all Object that receives basically an Action with some NUnit assertions like that:
public static class Be
{
public static Action<T> Equal(T to)
{
return (target) => NUnit.Framework.Assert.AreEqual(target, to);
}
}
The library is working pretty good but I have no tests for the library itself... basically because I don't know how to test it!
So, how can I test it? I mean, how to ensure that "object.Should(Be.Equal(object))" really checks the equality?