Skip to content

Instantly share code, notes, and snippets.

@derekgreer
Created June 11, 2011 15:56
Show Gist options
  • Save derekgreer/1020707 to your computer and use it in GitHub Desktop.
Save derekgreer/1020707 to your computer and use it in GitHub Desktop.
Custom Assertion Test
public class when_asserting_unsorted_comments_are_sorted_in_descending_order
{
static Exception _exception;
static List<Comment> _unsortedComments;
Establish context = () =>
{
_unsortedComments = new List<Comment>
{
new Comment("comment 1", DateTime.MinValue.AddDays(1)),
new Comment("comment 4", DateTime.MinValue.AddDays(4)),
new Comment("comment 3", DateTime.MinValue.AddDays(3)),
new Comment("comment 2", DateTime.MinValue.AddDays(2))
};
};
Because of = () => _exception = Catch.Exception(() => _unsortedComments.ShouldBeSortedByDateInDescendingOrder());
It should_throw_an_exception = () => _exception.ShouldBeOfType(typeof(Exception));
}
public class when_asserting_sorted_comments_are_sorted_in_descending_order
{
static Exception _exception;
static List<Comment> _unsortedComments;
Establish context = () =>
{
_unsortedComments = new List<Comment>
{
new Comment("comment 4", DateTime.MinValue.AddDays(4)),
new Comment("comment 3", DateTime.MinValue.AddDays(3)),
new Comment("comment 2", DateTime.MinValue.AddDays(2)),
new Comment("comment 1", DateTime.MinValue.AddDays(1))
};
};
Because of = () => _exception = Catch.Exception(() => _unsortedComments.ShouldBeSortedByDateInDescendingOrder());
It should_not_throw_an_exception = () => _exception.ShouldBeNull();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment