Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine caller name for EnumAssertions.Be #1835

Merged
merged 1 commit into from Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/EnumAssertions.cs
Expand Up @@ -57,7 +57,7 @@ public AndConstraint<TAssertions> Be(TEnum expected, string because = "", params
Execute.Assertion
.ForCondition(Subject?.Equals(expected) == true)
.BecauseOf(because, becauseArgs)
.FailWith("Expected the enum to be {0}{reason}, but found {1}.",
.FailWith("Expected {context:the enum} to be {0}{reason}, but found {1}.",
expected, Subject);

return new AndConstraint<TAssertions>((TAssertions)this);
Expand Down
4 changes: 2 additions & 2 deletions Src/FluentAssertions/Primitives/NullableEnumAssertions.cs
Expand Up @@ -42,7 +42,7 @@ public NullableEnumAssertions(TEnum? subject)
Execute.Assertion
.ForCondition(Subject.HasValue)
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:nullable date and time} to have a value{reason}, but found {0}.", Subject);
.FailWith("Expected {context:nullable enum} to have a value{reason}, but found {0}.", Subject);
jnyrup marked this conversation as resolved.
Show resolved Hide resolved

return new AndWhichConstraint<TAssertions, TEnum>((TAssertions)this, Subject.GetValueOrDefault());
}
Expand Down Expand Up @@ -77,7 +77,7 @@ public AndConstraint<TAssertions> NotHaveValue(string because = "", params objec
Execute.Assertion
.ForCondition(!Subject.HasValue)
.BecauseOf(because, becauseArgs)
.FailWith("Did not expect {context:nullable date and time} to have a value{reason}, but found {0}.", Subject);
.FailWith("Did not expect {context:nullable enum} to have a value{reason}, but found {0}.", Subject);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down
Expand Up @@ -169,7 +169,7 @@ public void When_enums_are_unequal_it_should_throw()

// Assert
act.Should().Throw<XunitException>()
.WithMessage("*because we want to test the failure message*");
.WithMessage("*subject*because we want to test the failure message*");
}

[Theory]
Expand Down
1 change: 1 addition & 0 deletions docs/_pages/releases.md
Expand Up @@ -14,6 +14,7 @@ sidebar:
* Added the ability to exclude fields & properties marked as non-browsable in the code editor from structural equality equivalency comparisons - [#1807](https://github.com/fluentassertions/fluentassertions/pull/1807)

### Fixes
* `EnumAssertions.Be` did not determine the caller name - [#1835](https://github.com/fluentassertions/fluentassertions/pull/1835)

### Fixes (Extensibility)

Expand Down