Skip to content

Caller identification always ignores the caller of a chained assertion #2747

@dennisdoomen

Description

@dennisdoomen

Description

Take for example

methodInfo.Should().BeDecoratedWith<DummyMethodAttribute>().Which.Filter.Should().BeFalse();

Even if the call to BeDecoratedWith succeeds and modifies the AssertionChain to report DummyMethodAttribute as the caller identification via the AndWhichConstraint to Which, the next call to Should().BeFalse() will still report methodInfo instead of DummyMethodAttribute.Filter. CallerStatementBuilder simply stops when it encounters the first .Should call.

Reproduction Steps

See test When_a_method_is_decorated_with_an_attribute_it_should_allow_chaining_assertions_on_it

methodInfo.Should().BeDecoratedWith<DummyMethodAttribute>().Which.Filter.Should().BeFalse();

Expected behavior

Expected DummyMethodAttribute.Filter to be False, but found True.

Actual behavior

Expected methodInfo to be False, but found True.

Regression?

No

Known Workarounds

None

Configuration

Fluent Assertions 7.0 with the new AssertionChain

Other information

  • Same with TypeAssertions.BeDecoratedWith and BeDecoratedWithOrInherit

Are you willing to help with a pull-request?

Yes, please assign this issue to me.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions