Class ResultAssertions<TValue>
Contains assertion methods for Result types.
public class ResultAssertions<TValue> : ReferenceTypeAssertions<Result<TValue>, ResultAssertions<TValue>>
Type Parameters
TValue
- Inheritance
-
ResultAssertions<TValue>
- Inherited Members
- Extension Methods
Constructors
ResultAssertions(Result<TValue>)
Initializes a new instance of the ResultAssertions<TValue> class.
public ResultAssertions(Result<TValue> result)
Parameters
resultResult<TValue>
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
BeFailure(string, params object[])
Asserts that the result is a failure.
public AndWhichConstraint<ResultAssertions<TValue>, Error> BeFailure(string because = "", params object[] becauseArgs)
Parameters
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
- AndWhichConstraint<ResultAssertions<TValue>, Error>
BeFailureOfType<TError>(string, params object[])
Asserts that the result is a failure with a specific error type.
public AndWhichConstraint<ResultAssertions<TValue>, TError> BeFailureOfType<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<ResultAssertions<TValue>, TError>
Type Parameters
TErrorThe expected error type.
BeSuccess(string, params object[])
Asserts that the result is a success.
public AndWhichConstraint<ResultAssertions<TValue>, TValue> BeSuccess(string because = "", params object[] becauseArgs)
Parameters
becausestringA formatted phrase as is supported by Format(string, params object[]) explaining why the assertion is needed. If the phrase does not start with the word because, it is prepended automatically.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
- AndWhichConstraint<ResultAssertions<TValue>, TValue>
HaveErrorCode(string, string, params object[])
Asserts that the failure has a specific error code.
public AndConstraint<ResultAssertions<TValue>> HaveErrorCode(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
- AndConstraint<ResultAssertions<TValue>>
HaveErrorDetail(string, string, params object[])
Asserts that the failure has a specific error detail.
public AndConstraint<ResultAssertions<TValue>> HaveErrorDetail(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
- AndConstraint<ResultAssertions<TValue>>
HaveErrorDetailContaining(string, string, params object[])
Asserts that the failure error detail contains the specified substring.
public AndConstraint<ResultAssertions<TValue>> HaveErrorDetailContaining(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
- AndConstraint<ResultAssertions<TValue>>
HaveValue(TValue, string, params object[])
Asserts that the success value equals the expected value.
public AndConstraint<ResultAssertions<TValue>> HaveValue(TValue expectedValue, string because = "", params object[] becauseArgs)
Parameters
expectedValueTValueThe expected value.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
- AndConstraint<ResultAssertions<TValue>>
HaveValueEquivalentTo(TValue, string, params object[])
Asserts that the success value is equivalent to the expected value using structural comparison.
public AndConstraint<ResultAssertions<TValue>> HaveValueEquivalentTo(TValue expectedValue, string because = "", params object[] becauseArgs)
Parameters
expectedValueTValueThe expected value.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
- AndConstraint<ResultAssertions<TValue>>
HaveValueMatching(Func<TValue, bool>, string, params object[])
Asserts that the success value satisfies a predicate.
public AndConstraint<ResultAssertions<TValue>> HaveValueMatching(Func<TValue, bool> predicate, string because = "", params object[] becauseArgs)
Parameters
predicateFunc<TValue, bool>The predicate the value should satisfy.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
- AndConstraint<ResultAssertions<TValue>>