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
ExceptionHasMessage, HasParamName, HasHResult, HasInner, HasRecursiveInnerExceptions
ObjectIsEqualTo, IsSameAs, Is<T>, IsNull, Satisfies, CompliesWith, IsCollected
EquivalencyIsEquivalentTo and its options

A few rules apply to all of these pages:

  • The object expectations, such as IsNull, IsSameAs, Is<T>, Satisfies, CompliesWith or IsEquivalentTo, work on every subject, also on the types of the other 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. They have no negated twin, so the overview tables list "negated comparison" for them: negate the comparison instead, e.g. HasLength().NotEqualTo(3).
  • The options page lists the options that several expectations share, e.g. a tolerance with Within or the string options.