AssertionExtensions
Extension methods for performing assertions
public static class AssertionExtensions
Namespace
Methods
MustContainKey
Asserts that a key must be present in a dictionary, and that it's value must not be null or empty
public static void MustContainKey(this IDictionary<string, string> dictionary, string key,
string paramName)
Parameters
Parameter | Description |
---|---|
dictionary |
The dictionary to check |
key |
The key to look for |
paramName |
A friendly parameter name to display in the assertion exception if the assertion fails |
Exceptions
Exception | Condition |
---|---|
ArgumentException |
Thrown if the given key is not present in the dictionary, or if it's value is null or empty |
MustEqual<T>
Asserts that a parameter is equal to another value
public static void MustEqual<T>(this T param, T compareTo, string paramName)
Parameters
Parameter | Description |
---|---|
T |
The Type of the parameter |
param |
The parameter to check |
compareTo |
The parameter to compare to |
paramName |
A friendly parameter name to display in the assertion exception if the assertion fails |
Exceptions
Exception | Condition |
---|---|
ArgumentNullException |
Thrown if the given parameter is null |
MustNotBeNull<T>
Asserts that a parameter must not be null
public static void MustNotBeNull<T>(this T param, string paramName)
where T : class
Parameters
Parameter | Description |
---|---|
T |
The Type of the parameter |
param |
The parameter to check |
paramName |
A friendly parameter name to display in the assertion exception if the assertion fails |
Exceptions
Exception | Condition |
---|---|
ArgumentNullException |
Thrown if the given parameter is null |
MustNotBeNullOrEmpty
Asserts that a parameter must not be null or empty
public static void MustNotBeNullOrEmpty(this string param, string paramName)
Parameters
Parameter | Description |
---|---|
param |
The parameter to check |
paramName |
A friendly parameter name to display in the assertion exception if the assertion fails |
Exceptions
Exception | Condition |
---|---|
ArgumentException |
Thrown if the given parameter is null or empty |
MustNotBeNullOrWhiteSpace
Asserts that a parameter must not be null or white space
public static void MustNotBeNullOrWhiteSpace(this string param, string paramName)
Parameters
Parameter | Description |
---|---|
param |
The parameter to check |
paramName |
A friendly parameter name to display in the assertion exception if the assertion fails |
Exceptions
Exception | Condition |
---|---|
ArgumentException |
Thrown if the given parameter is null or white space |