Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unecessary call to Subject.Should() #2402

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ public AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(IEnumerable<TE

using (var scope = new AssertionScope())
{
Subject.Should().BeEquivalentTo(unexpected, config);
BeEquivalentTo(unexpected, config);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding methods called SubjectShouldXXXX(...) which just calls XXX(...)? It's just for the fluent readability 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or... 😉

Subject.Should().Subject.Should().Subject.Should().Subject.Should().Foo();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.. got it ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tounge-Twister ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


failures = scope.Discard();
}
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/ObjectAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(

using (var scope = new AssertionScope())
{
Subject.Should().BeEquivalentTo(unexpected, config);
BeEquivalentTo(unexpected, config);
hasMismatches = scope.Discard().Length > 0;
}

Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/StringAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public AndConstraint<TAssertions> NotBeEquivalentTo(string unexpected, string be

using (var scope = new AssertionScope())
{
Subject.Should().BeEquivalentTo(unexpected);
BeEquivalentTo(unexpected);
notEquivalent = scope.Discard().Length > 0;
}

Expand Down