You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation, with the standard method Should().Be(), the Enum comparison should work the same as the .NET Implementation Enum.Equals() method.
However, with the following code this does not work for me.
publicenumMyEnumResult{Successfully,Failed}publicenumMySecondEnumResult{Successfully,AnotherValue,Failed}[Test]publicvoidMyTest(){MyEnumResultresult= _sut.Get(_id);//This works as expected
result.Should().Be(MyEnumResult.Successfully);//This works also, but should not
result.Should().Be(MySecondEnumResult.Successfully);}
Although the two enums are not of the same type, the test does not fail. Apparently only the underlying value is tested, but not the type.
Versions
Fluent Assertions version is 5.10.3
.NET framework 4.7.2
The text was updated successfully, but these errors were encountered:
Thanks for highlighting this inconsistency of Be for enums.
If you use HaveFlag instead, this should work as expected.
In the upcoming v6 this should be more visible due to #1375.
We also have discussions about reworking this further, see #1204.
Another case of inconsistency is #1208
Description
According to the documentation, with the standard method Should().Be(), the Enum comparison should work the same as the .NET Implementation Enum.Equals() method.
However, with the following code this does not work for me.
Although the two enums are not of the same type, the test does not fail. Apparently only the underlying value is tested, but not the type.
Versions
The text was updated successfully, but these errors were encountered: