public Continuation FailWith(Func <FailReason> failReasonFunc) { if (predecessorSucceeded) { return(predecessor.FailWith(failReasonFunc)); } return(new Continuation(predecessor, false)); }
/// <summary> /// Sets the failure message when the assertion is not met, or completes the failure message set to a /// prior call to to <see cref="WithExpectation"/>. /// </summary> /// <remarks> /// In addition to the numbered <see cref="string.Format(string,object[])"/>-style placeholders, messages may contain a few /// specialized placeholders as well. For instance, {reason} will be replaced with the reason of the assertion as passed /// to <see cref="BecauseOf"/>. Other named placeholders will be replaced with the <see cref="Current"/> scope data /// passed through <see cref="AddNonReportable"/> and <see cref="AddReportable"/>. Finally, a description of the /// current subject can be passed through the {context:description} placeholder. This is used in the message if no /// explicit context is specified through the <see cref="AssertionScope"/> constructor. /// Note that only 10 <paramref name="args"/> are supported in combination with a {reason}. /// If an expectation was set through a prior call to <see cref="WithExpectation"/>, then the failure message is appended to that /// expectation. /// </remarks> /// <param name="message">The format string that represents the failure message.</param> /// <param name="args">Optional arguments to any numbered placeholders.</param> public ContinuationOfGiven <T> FailWith(string message, params Func <T, object>[] args) { if (evaluateCondition) { parentScope.FailWith(message, args.Select(a => a(subject)).ToArray()); } return(new ContinuationOfGiven <T>(this, parentScope)); }
/// <remarks> /// <inheritdoc cref="IAssertionScope.FailWith(string, object[])"/> /// The <paramref name="args"/> will not be invoked if the prior assertion failed, /// nor will <see cref="FailWith(string, object[])"/> throw any exceptions. /// </remarks> /// <inheritdoc cref="IAssertionScope.FailWith(string, object[])"/> public ContinuationOfGiven <T> FailWith(string message, params object[] args) { if (continueAsserting) { continueAsserting = predecessor.FailWith(message, args); return(new ContinuationOfGiven <T>(this, continueAsserting)); } return(new ContinuationOfGiven <T>(this, succeeded: false)); }
/// <summary> /// Sets the failure message when the assertion is not met, or completes the failure message set to a /// prior call to to <see cref="WithExpectation"/>. /// </summary> /// <remarks> /// In addition to the numbered <see cref="string.Format(string,object[])"/>-style placeholders, messages may contain a few /// specialized placeholders as well. For instance, {reason} will be replaced with the reason of the assertion as passed /// to <see cref="BecauseOf"/>. Other named placeholders will be replaced with the <see cref="Current"/> scope data /// passed through <see cref="AddNonReportable"/> and <see cref="AddReportable"/>. Finally, a description of the /// current subject can be passed through the {context:description} placeholder. This is used in the message if no /// explicit context is specified through the <see cref="AssertionScope"/> constructor. /// Note that only 10 <paramref name="args"/> are supported in combination with a {reason}. /// If an expectation was set through a prior call to <see cref="WithExpectation"/>, then the failure message is appended to that /// expectation. /// </remarks> /// <param name="message">The format string that represents the failure message.</param> /// <param name="args">Optional arguments to any numbered placeholders.</param> public ContinuationOfGiven <T> FailWith(string message, params object[] args) { bool succeeded = parentScope.Succeeded; if (evaluateCondition) { Continuation continuation = parentScope.FailWith(message, args); succeeded = continuation.SourceSucceeded; } return(new ContinuationOfGiven <T>(this, succeeded)); }
/// <summary> /// Sets the failure message when the assertion is not met, or completes the failure message set to a /// prior call to <see cref="FluentAssertions.Execution.AssertionScope.WithExpectation"/>. /// </summary> /// <remarks> /// In addition to the numbered <see cref="string.Format(string, object[])"/>-style placeholders, messages may contain /// a few specialized placeholders as well. For instance, {reason} will be replaced with the reason of the assertion as /// passed to <see cref="FluentAssertions.Execution.AssertionScope.BecauseOf"/>. Other named placeholders will be /// replaced with the <see cref="FluentAssertions.Execution.AssertionScope.Current"/> scope data passed through /// <see cref="FluentAssertions.Execution.AssertionScope.AddNonReportable"/> and /// <see cref="FluentAssertions.Execution.AssertionScope.AddReportable"/>. Finally, a description of the /// current subject can be passed through the {context:description} placeholder. This is used in the message if no /// explicit context is specified through the <see cref="AssertionScope"/> constructor. /// Note that only 10 <paramref name="args"/> are supported in combination with a {reason}. /// If an expectation was set through a prior call to /// <see cref="FluentAssertions.Execution.AssertionScope.WithExpectation"/>, then the failure message is appended /// to that expectation. /// </remarks> /// <param name="message">The format string that represents the failure message.</param> /// <param name="args">Optional arguments to any numbered placeholders.</param> public ContinuationOfGiven <T> FailWith(string message, params object[] args) { bool succeeded = predecessorSucceeded; if (predecessorSucceeded) { Continuation continuation = predecessor.FailWith(message, args); succeeded = continuation.SourceSucceeded; } return(new ContinuationOfGiven <T>(this, succeeded)); }