Skip to content

Commit

Permalink
Determine caller name for EnumAssertions.Be
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyrup committed Mar 6, 2022
1 parent 418a405 commit c950341
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
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);

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 - [#1833](https://github.com/fluentassertions/fluentassertions/pull/1833)

### Fixes (Extensibility)

Expand Down

0 comments on commit c950341

Please sign in to comment.