Skip to content

BeEquivalentTo fails with default interface methods (6.12.1) #2759

@dusk0r

Description

@dusk0r

Description

Comparing the same Interface with BeEquivalentTo() fails if the interface contains default interface methods.

Reproduction Steps

    public void BeEquivalentTo_Default_Interface_Method()
    {
        List<ITest> lista = [new Test { Name = "Test" }];
        List<ITest> listb = [new Test { Name = "Test" }];

        lista.Should().BeEquivalentTo(listb); // Fails with: Expectation has property lista[0].NameLength that the other object does not have.
    }
    
    public class Test : ITest
    {
        public string Name { get; set; }
    }

    public interface ITest
    {
        public string Name { get; }
        public int NameLength => Name.Length;
    }

Expected behavior

Doesn't thorw an exception.

Actual behavior

Fails with: Expectation has property lista[0].NameLength that the other object does not have.

Regression?

This worked in 6.12.0 and before but fails in 6.12.1.

Known Workarounds

No response

Configuration

Fluent Assertion 6.12.1
.net 8.0.401

Other information

No response

Are you willing to help with a pull-request?

No

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions