Skip to content

Equivalency assertion for dictionary does not include because message #2293

@jnyrup

Description

@jnyrup

Description

When comparing the values of dictionaries for equivalency, the because message is not included in the failure message.

Reproduction Steps

var subject = new Dictionary<string, object>
{
    ["a"] = new List<int>()
};

var expected = new Dictionary<string, object>
{
    ["a"] = new List<int> { 42 }
};

subject.Should().BeEquivalentTo(expected, "FOO");

Expected behavior

Exception message should include FOO

Actual behavior

FluentAssertions.Execution.AssertionFailedException: 'Expected subject[a] to be a collection with 1 item(s), but found an empty collection.

With configuration:
- Use declared types and members
- Compare enums by value
- Compare tuples by their properties
- Compare anonymous types by their properties
- Compare records by their members
- Include non-browsable members
- Match member by name (or throw)
- Be strict about the order of items in byte arrays
- Without automatic conversion.
'

Regression?

no

Known Workarounds

No response

Configuration

Fluent Assertions 6.12
.NET 8.0

Other information

No response

Could you help with a pull-request?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions