fluentassertions icon indicating copy to clipboard operation
fluentassertions copied to clipboard

Some parent equivalency options are not included in failure message

Open jnyrup opened this issue 4 years ago • 0 comments

Description

When the global default equivalency assertion options are modified, they are not included in the failure message.

Complete minimal example reproducing the issue

public class MyClass
{
    public int Value { get; set; }
}

Local options

var subject = new MyClass { Value = 1 };
var expected = new MyClass { Value = 1 };
subject.Should().BeEquivalentTo(expected, opt => opt.ComparingByValue<MyClass>());

Global options

AssertionOptions.AssertEquivalencyUsing(opt => opt.ComparingByValue<MyClass>());

var subject = new MyClass { Value = 1 };
var expected = new MyClass { Value = 1 };
subject.Should().BeEquivalentTo(expected);

Expected behavior:

Both failure messages should include the line

- Compare FluentAssertions.Specs.MyClass by value

Actual behavior:

Only the local variant includes the expected line in the failure message.

Versions

  • Which version of Fluent Assertions are you using; 6.1.0
  • Which .NET runtime and version are you targeting? .NET5

jnyrup avatar Oct 24 '21 09:10 jnyrup