Skip to content

Misleading caller identity when Which fails #1502

@jnyrup

Description

@jnyrup

Description

When chaining into an assertion using Which the failure message can be confusing, when the inner assertion fails, as the determined caller identity is from the outer assertion.

Complete minimal example reproducing the issue

var languages = new[] { "C#" };

languages.Should().ContainSingle()
    .Which.Should().EndWith("script");

Expected behavior:

Some nice message about "C#" not ending with "script".

Actual behavior:

Expected languages to end with "script", but "C#" is too short.

Versions

  • latest version of develop: ee0aa43

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions