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

Add ForConstraint to AssertionScope to open up OccurenceConstraint for usage in custom assertion extensions #1341

Conversation

rynkevich
Copy link
Contributor

Improves library extension interface as requested in #1281.

Some equivalent ForCondition usages are replaced with ForOccurrences (StringAssertions.Contain and StringAssertions.ContainEquivalentOf), and as methods containing them covered with unit test, I consider ForOccurrences covered enough as well.

The existence of {expectedOccurrences} placeholder is mentioned in documentation comment for ForOccurrences method. I don't think it should be in FailWith doc comment as it would make it too large and hard to read.

IMPORTANT

  • The code complies with the Coding Guidelines for C#.
  • The changes are covered by a new or existing set of unit tests which follow the Arrange-Act-Assert syntax such as is used in this example.
  • If the contribution adds a feature or fixes a bug, please update the release notes, which are published on the website.
  • If the contribution changes the public API the changes needs to be included by running AcceptApiChanges.ps1/AcceptApiChanges.sh.
  • If the contribution affects the documentation, please include your changes in this pull request so the documentation will appear on the website.

@@ -678,10 +678,10 @@ public AndConstraint<TAssertions> Contain(string expected, OccurrenceConstraint
int actual = Subject.CountSubstring(expected, StringComparison.Ordinal);

Execute.Assertion
.ForCondition(occurrenceConstraint.Assert(actual))
.ForOccurrences(occurrenceConstraint, actual)
Copy link
Member

Choose a reason for hiding this comment

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

I think ForConstraint will work better, but I'm not 100% sure. I even ask Twitterverse for some guidance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess that guys in Twitter aren't actually getting the context for these concepts. IMHO ForConstraint will work just fine, it's correct in technical sense.

@rynkevich rynkevich changed the title Add ForOccurrences to AssertionScope to open up OccurenceConstraint for usage in custom assertion extensions Add ForConstraint to AssertionScope to open up OccurenceConstraint for usage in custom assertion extensions Jun 1, 2020
@rynkevich rynkevich force-pushed the feature/1281-open-up-occurrence-constraint branch from febeb61 to 3baa7bc Compare June 1, 2020 22:24
@dennisdoomen dennisdoomen requested a review from jnyrup June 2, 2020 10:00
Copy link
Member

@jnyrup jnyrup left a comment

Choose a reason for hiding this comment

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

LGTM.
I'm repeatedly amazed about how much FA users apparently extend the library.

It would be nice having a test that adds a custom OccurrenceConstraint to exemplify the purpose of ForConstraint for library consumer.

@dennisdoomen dennisdoomen merged commit 84753f4 into fluentassertions:develop Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants