The Should library

The Should library gives developers an expressive way to assert the expected outcome of a test.

Instead of writing assertions like this:

public void then_it_credits_the_account()
     Assert.Equals(15.63, _accountBalance);

The library provides extension methods that make assertions read more like English and thus are more friendly for humans:

public void then_it_credits_the_account()

Below are some examples of extension methods provided by the Should library.


_purchaseConfirmation.ShouldEqual("Your purchase completed successfully");
_purchaseConfirmation.ShouldNotEqual("Your credit card was declined");

// Booleans

// Strings
"This could be a really long string".ShouldContain("really long string");
"This could be a really long string".ShouldNotContain("something that shouldn't be here");
"This string contains text".ShouldNotBeEmpty();

// Lists
_tags.ShouldContain("Green", "Blue");