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
  • ShouldBeGreaterThan
  • ShouldBeGreaterThanOrEqualTo
  • ShouldBeLessThan
  • ShouldBeLessThanOrEqualTo
Edit on GitHub
  1. Documentation
  2. Equality

Greater/Less Than

PreviousOneOfNextInRange

Last updated 2 years ago

ShouldBeGreaterThan is the inverse of ShouldBeLessThan.

ShouldBeGreaterThan

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

|

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

|

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

Exception

homer.Salary
    should be less than
30000
    but was
300000000

ShouldBeLessThanOrEqualTo

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

Exception

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

|

|

snippet source
snippet source
anchor
anchor
snippet source
anchor
snippet source
anchor