-
Notifications
You must be signed in to change notification settings - Fork 731
Open
Labels
Description
Description
I want to be able to configure FluentAssertions' structural equality so that it uses ComparingByMembers for all types.
The background for this is that I have a mix of F# and C# code and all F# records implement Equals by default. In case of an object-graph with a mix starts using Equals when hitting the first F# record, as well for the nested C# classes.
I tried ComparingByMembers<object>, but that results in the tests always being succeeded. And I guess that should be fixed.
Complete minimal example reproducing the issue
using FluentAssertions;
using Xunit;
namespace CSharp.FluentAssertionWrapper
{
public class Facts
{
public struct C
{
public D D { get; set; }
}
public class D
{
public string S { get; set; }
public int I { get; set; }
}
[Fact]
public void Foo()
{
var a = new C { D = new D { S = "a", I = 17 } };
var b = new C { D = new D { S = "a", I = 18 } };
a.Should().BeEquivalentTo( // this should fail, but succeeds
b,
config => config.ComparingByMembers<object>());
}
}
}Expected behavior:
All types are structurally compared correctly.
Actual behavior:
Assertion always succeeds.
Versions
- Which version of Fluent Assertions are you using? 5.10.3
- Which .NET runtime and version are you targeting? netcoreapp3.1
Additional Information
None.
pihai and BrunoJuchli