Visual Studio Unit Testing Extensions v1.0.0.0 - Continued...

Last night I wrote a post about the Visual Studio Unit Testing Extensions that I put out on CodePlex.  I forgot to mention one of my favorite features that the library provides.

I showed how you can use the library to write readable unit tests like the following:

 [TestMethod]
 public void NewWay_Test()
 {
    int number = 5;
    number.ShouldEqual(5);
    number.ShouldBeGreaterThan(4);
    number.ShouldBePositive();
 }

Another
feature of this library is the ability to chain assertions. Each
assertion method returns the original source value, so the same test
above can also be written the following way:

 [TestMethod]
 public void NewWay_Test()
 {
    int number = 5;
    number.ShouldEqual(5)
       .ShouldBeGreaterThan(4)
       .ShouldBePositive();
 }

I think that this makes the unit test even more readable and also reduces the amount of code that is needed.

If you can think of any features or assertion methods that you would like to see added to the library, please let me know either by commenting on this post or at the CodePlex discussion site.

Comments