fluentassertions / fluentassertions/fluentassertions

Some parent equivalency options are not included in failure message

Open
#1,721 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
3.8k
Forks
720
Avg merge
1d 1h
Merged PRs (30d)
29

Description

### Description

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

### Complete minimal example reproducing the issue

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

#### Local options
```cs
var subject = new MyClass { Value = 1 };
var expected = new MyClass { Value = 1 };
subject.Should().BeEquivalentTo(expected, opt => opt.ComparingByValue());
```

#### Global options
```cs
AssertionOptions.AssertEquivalencyUsing(opt => opt.ComparingByValue());

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.