Shouldly
  • Overview
  • Contributing
  • Documentation
    • Getting Started
    • Configuration
    • Equality
      • ShouldBe
      • NotBe
      • Null
      • Bool
      • Flags
      • AssignableTo
      • OfType
      • OneOf
      • Greater/Less Than
      • InRange
      • MatchApproved
      • Enumerable
      • SameAs
      • String
      • ExampleClasses
    • String
      • ShouldBe
      • Match
      • Contain
      • Null and Empty
      • StartWith
      • EndWith
    • Enumerable
      • ShouldBe
      • All
      • Empty
      • OneOf
      • Contain
      • Unique
      • SubsetOf
      • Have
    • Dictionary
      • ContainKey
      • ContainKeyAndValue
    • Exceptions
      • Throw
      • NotThrow
    • SatisfyAllConditions
    • CompleteIn
    • DynamicShould
    • Upgrade 3 to 4
Powered by GitBook
On this page
  • ShouldBeInRange
  • ShouldNotBeInRange
Edit on GitHub
  1. Documentation
  2. Equality

InRange

PreviousGreater/Less ThanNextMatchApproved

Last updated 2 years ago

ShouldBeInRange is the inverse of ShouldNotBeInRange.

ShouldBeInRange

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

|

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);

|

Exception

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