Class ErrorAssertions
Contains assertion methods for Error types.
public class ErrorAssertions : ReferenceTypeAssertions<Error, ErrorAssertions>
- Inheritance
-
ErrorAssertions
- Inherited Members
- Extension Methods
Constructors
ErrorAssertions(Error)
Initializes a new instance of the ErrorAssertions class.
public ErrorAssertions(Error error)
Parameters
errorError
Properties
Identifier
Returns the type of the subject the assertion applies on. It should be a user-friendly name as it is included in the failure message.
protected override string Identifier { get; }
Property Value
Methods
Be(Error, string, params object[])
Asserts that the error equals the expected error (based on Error.Equals which compares by Code).
public AndConstraint<ErrorAssertions> Be(Error expected, string because = "", params object[] becauseArgs)
Parameters
expectedErrorThe expected error.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
BeOfType<TError>(string, params object[])
Asserts that the error is of the specified type and returns a typed constraint for further assertions.
public AndWhichConstraint<ErrorAssertions, TError> BeOfType<TError>(string because = "", params object[] becauseArgs) where TError : Error
Parameters
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
- AndWhichConstraint<ErrorAssertions, TError>
Type Parameters
TErrorThe expected error type.
HaveCode(string, string, params object[])
Asserts that the error has the specified code.
public AndConstraint<ErrorAssertions> HaveCode(string expectedCode, string because = "", params object[] becauseArgs)
Parameters
expectedCodestringThe expected error code.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
HaveDetail(string, string, params object[])
Asserts that the error has the specified detail message.
public AndConstraint<ErrorAssertions> HaveDetail(string expectedDetail, string because = "", params object[] becauseArgs)
Parameters
expectedDetailstringThe expected error detail.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
HaveDetailContaining(string, string, params object[])
Asserts that the error detail contains the specified substring.
public AndConstraint<ErrorAssertions> HaveDetailContaining(string substring, string because = "", params object[] becauseArgs)
Parameters
substringstringThe substring to search for.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
HaveInstance(string, string, params object[])
Asserts that the error has the specified instance identifier.
public AndConstraint<ErrorAssertions> HaveInstance(string expectedInstance, string because = "", params object[] becauseArgs)
Parameters
expectedInstancestringThe expected instance identifier.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.