diff --git a/Src/FluentAssertions/Primitives/BooleanAssertions.cs b/Src/FluentAssertions/Primitives/BooleanAssertions.cs index b71e2f1dfb..705d753e56 100644 --- a/Src/FluentAssertions/Primitives/BooleanAssertions.cs +++ b/Src/FluentAssertions/Primitives/BooleanAssertions.cs @@ -123,7 +123,6 @@ public AndConstraint NotBe(bool unexpected, string because = "", pa /// Asserts that the value implies the specified value. /// /// The right hand side for the implication - /// If you want to use the `because` / `becauseArgs` construct, it is **necessary** to use the caller argument expression, because this would lead to unexpected failure messages, when omitted! /// /// A formatted phrase as is supported by explaining why the assertion /// is needed. If the phrase does not start with the word because, it is prepended automatically. @@ -132,7 +131,6 @@ public AndConstraint NotBe(bool unexpected, string because = "", pa /// Zero or more objects to format using the placeholders in . /// public AndConstraint Imply(bool consequent, - [CallerArgumentExpression(nameof(consequent))] string consequentMessage = "", string because = "", params object[] becauseArgs) { @@ -141,7 +139,7 @@ public AndConstraint Imply(bool consequent, Execute.Assertion .ForCondition(antecedent is not null) .BecauseOf(because, becauseArgs) - .WithExpectation($"Expected {{context:antecedent}} ({{0}}) to imply {consequentMessage} ({{1}}){{reason}}, ", antecedent, consequent) + .WithExpectation($"Expected {{context:antecedent}} ({{0}}) to imply consequent ({{1}}){{reason}}, ", antecedent, consequent) .FailWith("but found null.") .Then .ForCondition(!antecedent.Value || consequent) diff --git a/Tests/FluentAssertions.Specs/Primitives/BooleanAssertionSpecs.cs b/Tests/FluentAssertions.Specs/Primitives/BooleanAssertionSpecs.cs index 4ba09ed37a..afb14097d0 100644 --- a/Tests/FluentAssertions.Specs/Primitives/BooleanAssertionSpecs.cs +++ b/Tests/FluentAssertions.Specs/Primitives/BooleanAssertionSpecs.cs @@ -195,11 +195,11 @@ public void Subject_implies_implicator(bool? antecedent, bool consequent) public void Subject_does_not_imply_implicator(bool? antecedent, bool consequent) { // Act - Action act = () => antecedent.Should().Imply(consequent, nameof(consequent), "because we want to test the {0}", "failure"); + Action act = () => antecedent.Should().Imply(consequent, "because we want to test the {0}", "failure"); // Assert act.Should().Throw() - .WithMessage("Expected*to imply consequent*test the failure*but*"); + .WithMessage("Expected antecedent*to imply consequent*test the failure*but*"); } } } diff --git a/docs/_pages/booleans.md b/docs/_pages/booleans.md index 3e7d483d82..9adff0f6ae 100644 --- a/docs/_pages/booleans.md +++ b/docs/_pages/booleans.md @@ -28,12 +28,4 @@ Implication: see [here](https://mathworld.wolfram.com/Implies.html) ```csharp bool anotherBoolean = true; theBoolean.Should().Imply(anotherBoolean); -``` - -Passing a custom caller argument expression is beneficial for this assertion to get the second parameter name in the failure message -```csharp -bool anotherBoolean = true; -theBoolean.Should().Imply(anotherBoolean, nameof(anotherBoolean)); -``` - -If you want to use the `because` / `becauseArgs` construct, it is **necessary** to use the caller argument expression, because this would lead to unexpected failure messages, when omitted! \ No newline at end of file +``` \ No newline at end of file