-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
I decided to look at the source code after finding out that my enum assertions weren't identifying the subject name when using Be(), and yet it is identified correctly when using NotBe().
Apparently, in EnumAssertions.Be() (see line 60), {context:the enum} was not being used:
fluentassertions/Src/FluentAssertions/Primitives/EnumAssertions.cs
Lines 55 to 64 in 418a405
| public AndConstraint<TAssertions> Be(TEnum expected, string because = "", params object[] becauseArgs) | |
| { | |
| Execute.Assertion | |
| .ForCondition(Subject?.Equals(expected) == true) | |
| .BecauseOf(because, becauseArgs) | |
| .FailWith("Expected the enum to be {0}{reason}, but found {1}.", | |
| expected, Subject); | |
| return new AndConstraint<TAssertions>((TAssertions)this); | |
| } |
This doesn't match the counterpart NotBe() (see line 105):
fluentassertions/Src/FluentAssertions/Primitives/EnumAssertions.cs
Lines 99 to 108 in 418a405
| public AndConstraint<TAssertions> NotBe(TEnum unexpected, string because = "", | |
| params object[] becauseArgs) | |
| { | |
| Execute.Assertion | |
| .ForCondition(Subject?.Equals(unexpected) != true) | |
| .BecauseOf(because, becauseArgs) | |
| .FailWith("Expected {context:the enum} not to be {0}{reason}, but it is.", unexpected); | |
| return new AndConstraint<TAssertions>((TAssertions)this); | |
| } |
The above are permalinks but the issue currently exists in both the develop and master branches.