Skip to content

Failing .BeEquivalentTo<Enum>(..., because) should print because text #2213

@ArneMancofi

Description

@ArneMancofi

Description

When .BeEquivalentTo<Enum>(..., because-text) fails, it does not print the because-text.

Reproduction Steps

This gist demonstrates that the printed text depends on the element type:

public enum E { e0, e1, e2 }
    
[Fact]
public void FailingEnumSetEquivalenceTestShouldPrintReason()
{
  var xs0 = new[] { E.e1 };
  var xs1 = new[] { E.e2 };
  xs1.Should().BeEquivalentTo(xs0, "we expect them to be equivalent");
  // "Expected xs1[0] to equal E.e1 {value: 1} by value, but found E.e2 {value: 2}."
}

[Fact]
public void FailingIntSetEquivalenceTestShouldPrintReason()
{
  var xs0 = new[] { 1 };
  var xs1 = new[] { 2 };
  xs1.Should().BeEquivalentTo(xs0, "we expect them to be equivalent");
  // "Expected xs1[0] to be 1 because we expect them to be equivalent, but found 2."
}

Expected behavior

because-text should always be printed when an assertion fails.

Actual behavior

The because-text is not printed when the element type is an enum type.

Regression?

No response

Known Workarounds

No response

Configuration

Fluentassertions 6.11.0
Target: .NET 6

Other information

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions