Skip to main content

Values

Describes the possible expectations for single values, from bool and numbers to strings, streams and any object.

PageExpectations
BooleanIsTrue, IsFalse, Implies
NumberIsEqualTo, IsGreaterThan, IsBetween, IsPositive, IsNaN, Within
StringIsEqualTo with wildcards or regex, StartsWith, Contains, HasLength
CharIsEqualTo, categories like IsALetter or IsWhiteSpace
EnumIsEqualTo, HasValue, IsDefined, HasFlag
GuidIsEqualTo, IsEmpty, IsNullOrEmpty
VersionIsEqualTo, IsGreaterThan, IsBetween, HasMajor
StreamIsReadable, IsSeekable, HasLength, HasPosition
TimeSpanIsEqualTo, IsGreaterThan, IsBetween, IsPositive, Within
DateTime / DateTimeOffsetIsEqualTo, IsAfter, IsBefore, IsBetween, HasYear, Within
DateOnly / TimeOnlyIsEqualTo, IsAfter, IsBefore, IsBetween, HasYear
ObjectIsEqualTo, IsSameAs, Is<T>, IsNull, Satisfies, CompliesWith
EquivalencyIsEquivalentTo and its options

A few rules apply to all of these pages:

  • A null subject fails every expectation that inspects it, and its negation as well, as the rule for null subjects describes.
  • The Has… expectations, such as HasLength() or HasYear(), continue with a comparison like GreaterThan or Between, as shown for the length of a string.
  • The options page lists the options that several expectations share, e.g. a tolerance with Within or the string options.