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 NotContainEquivalentOf with OccurrenceConstraint parameter for string assertions #2436

Conversation

vbreuss
Copy link
Contributor

@vbreuss vbreuss commented Nov 4, 2023

As discussed in #2364 add an overload for NotContainEquivalentOf that takes an OccurenceConstraint parameter.

IMPORTANT

  • If the PR touches the public API, the changes have been approved in a separate issue with the "api-approved" label.
  • The code complies with the Coding Guidelines for C#.
  • The changes are covered by unit tests which follow the Arrange-Act-Assert syntax and the naming conventions such as is used in these tests.
  • If the PR adds a feature or fixes a bug, please update the release notes with a functional description that explains what the change means to consumers of this library, which are published on the website.
  • If the PR changes the public API the changes needs to be included by running AcceptApiChanges.ps1 or AcceptApiChanges.sh.
  • If the PR affects the documentation, please include your changes in this pull request so the documentation will appear on the website.
    • Please also run ./build.sh --target spellcheck or .\build.ps1 --target spellcheck before pushing and check the good outcome

@vbreuss vbreuss changed the title Add NotContainEquivalentOf with OccurrenceConstraint Add NotContainEquivalentOf with OccurrenceConstraint parameter for string assertions Nov 4, 2023
Copy link

github-actions bot commented Nov 4, 2023

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

  1. Register at Qodana Cloud and configure the action
  2. Use GitHub Code Scanning with Qodana
  3. Host Qodana report at GitHub Pages
  4. Inspect and use qodana.sarif.json (see the Qodana SARIF format for details)

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2023.2.8
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@coveralls
Copy link

coveralls commented Nov 4, 2023

Pull Request Test Coverage Report for Build 6755617618

  • 16 of 16 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.003%) to 97.39%

Totals Coverage Status
Change from base Build 6754534983: -0.003%
Covered Lines: 11751
Relevant Lines: 11942

💛 - Coveralls

/// </summary>
/// <param name="unexpected">The string that the subject is not expected to contain.</param>
/// <param name="occurrenceConstraint">
/// A constraint specifying the amount of times a substring should be present within the test subject.
Copy link
Member

Choose a reason for hiding this comment

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

🔧 This isn't clear for me. How does the occurrence work in combination with "should not contain equivalent of"?

@jnyrup
Copy link
Member

jnyrup commented Nov 4, 2023

I'm having second thoughts on combining negated assertions with OccurenceConstraints.

"abbbc".Should().NotContainEquivalentOf("b", MoreThan.Once());

can also be expressed as the affirmative

"abbbc".Should().ContainEquivalentOf("b", AtMost.Once());

It took me an extra minute (at least) to realize that I also had to negate the OccurenceConstraint to actually assert what I intended to and also remember that the negation of AtMost is MoreThan, not AtLeast.

@vbreuss
Copy link
Contributor Author

vbreuss commented Nov 4, 2023

I'm having second thoughts on combining negated assertions with OccurenceConstraints.

Okay, I will remove this also from #2413 and close this PR...

@vbreuss vbreuss closed this Nov 4, 2023
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

4 participants