. NET Test assertion Tool Shouldly.net test
shouldly Open Source address on GitHub: https://github.com/shouldly/shouldly
Shouldly's Official document: http://docs.shouldly-lib.net/
The Shouldly assertion Framework provides support for many aspects such as equality, iterations, dynamic variables, strings, dictionaries, Task/async, and exceptions.
Equality equal one of them
Shouldbeoneof
Shouldnotbeoneof
Greater than
Shouldbegreaterthan
Less than
Shouldbelessthan
Type
Shouldbeoftype
Can type conversions
Shouldbeassignableto
In a range
Shouldbeinrange
Shouldnotbeinrange
Enumeration collection starts with an object
Shouldstartwith
All elements in the collection meet the criteria
Shouldallbe
The collection contains an object
Shouldcontain
Shouldnotcontain
The collection contains elements that satisfy the condition
Shouldcontain (predicate)
Shouldnotcontain (predicate)
An empty collection for a collection
Shouldbeempty
Shouldnotbeempty
is one of them in the collection
Shouldbeoneof
is a subset of the collection object
Shouldbesubsetof
String contains keywords
Shouldcontainkey
String start and End
Shouldstartwith
Shouldnotstartwith
Shouldendwith
Shouldnotendwith
String contains
Shouldcontain
Shouldnotcontain
(Contains spaces)
Shouldcontainwithoutwhitespace
Match Regular expression
Shouldmatch
is an empty string or null
Shouldbenullorempty
Shouldnotbenullorempty
Dictionary contains key
Shouldnotcontainkey
Contains key and value
Shouldcontainkeyandvalue
Shouldnotcontainvalueforkey
Exception Throw exception
Shouldthrow
Shouldnotthrow
Shouldnotthrow (func<task>)
Asynchronous and synchronous throw exceptions
Shouldthrow
Owning property
Shouldhaveproperty
Complete
Completein
Dynamically meets all conditions
parameter is all assertions, all assertions are detected, and hints are given
Shouldsatisfyallconditions
. NET Test Assertion Tool shouldly