InRange

ShouldBeInRange is the inverse of ShouldNotBeInRange.

ShouldBeInRange

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

snippet source | anchor

Exception

homer.Salary
    should be in range
{ from = 30000, to = 40000 }
    but was
300000000

ShouldNotBeInRange

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

snippet source | anchor

Exception

mrBurns.Salary
    should not be in range
{ from = 30000, to = 40000 }
    but was
30000

Last updated