Remove unecessary call to Subject.Should()#2402
Conversation
Pull Request Test Coverage Report for Build 6650591818
💛 - Coveralls |
| using (var scope = new AssertionScope()) | ||
| { | ||
| Subject.Should().BeEquivalentTo(unexpected, config); | ||
| BeEquivalentTo(unexpected, config); |
There was a problem hiding this comment.
What about adding methods called SubjectShouldXXXX(...) which just calls XXX(...)? It's just for the fluent readability 😉
There was a problem hiding this comment.
Or... 😉
Subject.Should().Subject.Should().Subject.Should().Subject.Should().Foo();There was a problem hiding this comment.
I just realized you weren't joking 🤦♂️
I'm fine with the current proposed changed, but also happy to add a AssertSubjectIsEquivalentTo forwarding method.
Note that the three changed lines each call a different BeEquivalentTo method.
Avoiding calling Should() inside FA could help #2253
dennisdoomen
left a comment
There was a problem hiding this comment.
I see what you are trying to do, but it doesn't read very fluent to me.
One can hardly disagree that To get some numbers on the table, this pattern gives 134 results grep -rInE --include=*.cs '^ *(return|=>)? *[A-Z][A-Za-z]+\(.*because, becauseArgs' | wc -lThe vast majority are simple one-liner forwards to another overload. fluentassertions/Src/FluentAssertions/Primitives/ReferenceTypeAssertions.cs Lines 127 to 136 in 52622a0 fluentassertions/Src/FluentAssertions/NumericAssertionsExtensions.cs Lines 848 to 867 in 52622a0 Another pattern we use around a dozen places is to have non-public methods having Combined with #2403 the four ones calling |
Is this a third proposal (for #2403)? :) |
27cef01 to
dab1f3c
Compare

Unless
Subject.Should()resolves to a another overload ofShouldthan the initialsut.Should(), callingSubject.Should().Foo()instead ofFoo()directly should not add any value, but on the negative side lengthen the stack trace in case the assertion fails.IMPORTANT
./build.sh --target spellcheckor.\build.ps1 --target spellcheckbefore pushing and check the good outcome