Greater/Less Than

ShouldBeGreaterThan is the inverse of ShouldBeLessThan.

ShouldBeGreaterThan

var mrBurns = new Person { Name = "Mr. Burns", Salary = 30000 };
mrBurns.Salary.ShouldBeGreaterThan(300000000);

snippet source | anchor

Exception

mrBurns.Salary
    should be greater than
300000000
    but was
30000

ShouldBeGreaterThanOrEqualTo

var mrBurns = new Person { Name = "Mr. Burns", Salary = 299999999 };
mrBurns.Salary.ShouldBeGreaterThanOrEqualTo(300000000);

snippet source | anchor

Exception

mrBurns.Salary
    should be greater than or equal to
300000000
    but was
299999999

ShouldBeLessThan

var homer = new Person { Name = "Homer", Salary = 300000000 };
homer.Salary.ShouldBeLessThan(30000);

snippet source | anchor

Exception

homer.Salary
    should be less than
30000
    but was
300000000

ShouldBeLessThanOrEqualTo

var homer = new Person { Name = "Homer", Salary = 30001 };
homer.Salary.ShouldBeLessThanOrEqualTo(30000);

snippet source | anchor

Exception

homer.Salary
    should be less than or equal to
30000
    but was
30001

Last updated