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

Handle comparing an IDictionary subject with an IDictionary<,> expectation #2358

Merged
merged 2 commits into from
Oct 14, 2023

Conversation

ITaluone
Copy link
Contributor

@ITaluone ITaluone commented Oct 3, 2023

Fixes: #2308

Note: The very first two commits are to fix the actual problem. Commit 3-6 are for code quality (and therefore can moved to a separate PR if needed).

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

@github-actions
Copy link

github-actions bot commented Oct 3, 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.6
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@ITaluone
Copy link
Contributor Author

ITaluone commented Oct 3, 2023

Out of curiosity:

Should this test fail or pass?

[Fact]
public void A_enumerable_of_key_value_pairs_and_generic_dict()
{
    var subject = new List<KeyValuePair<string, object>>
    {
        new("id", 22),
        new("CustomerId", 33)
    };

    var expected = new Dictionary<object, object>
    {
        ["id"] = 22,
        ["CustomerId"] = 33
    };

    subject.Should().BeEquivalentTo(expected);
}

Edit: Oh.. it does 🙈 (with KeyValuePair<object, object>)...

@ITaluone ITaluone force-pushed the fix/issue-2308 branch 2 times, most recently from 5dbdcf0 to 03a21cf Compare October 3, 2023 10:07
@coveralls
Copy link

coveralls commented Oct 3, 2023

Pull Request Test Coverage Report for Build 6472389490

  • 21 of 21 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 97.402%

Totals Coverage Status
Change from base Build 6464892225: 0.02%
Covered Lines: 11655
Relevant Lines: 11846

💛 - Coveralls

@ITaluone ITaluone changed the title Handle non-generic dictionary subject when compared with a generic dictionary expectation Handle comparing an IDictionary subject with an IDictionary<,> expectation Oct 3, 2023
@ITaluone ITaluone force-pushed the fix/issue-2308 branch 5 times, most recently from ccef602 to 685f631 Compare October 5, 2023 07:25
@dennisdoomen
Copy link
Member

dennisdoomen commented Oct 8, 2023

The very first two commits are to fix the actual problem. Commit 3-6 are for code quality (and therefore can moved to a separate PR if needed).

It's totally fine to combine the fix and the refactorings in a single PR. But that requires you to ensure that every commit has a clear purpose so that we can review them one by one and we can rebase-merge them. But in your case, it looks like some commits are rework on earlier commits. Same for the "release notes" commit.

@IT-VBFK
Copy link
Contributor

IT-VBFK commented Oct 8, 2023

But that requires you to ensure that every commit has a clear purpose so that we can review them one by one and we can rebase-merge them. But in your case, it looks like some commits are rework on earlier commits. Same for the "release notes" commit.

How can a refactoring commit be a "non-rework" of previous commits? 🤔

@ITaluone
Copy link
Contributor Author

ITaluone commented Oct 8, 2023

@dennisdoomen I have combined all commits to one, because I had no clue, how I could add refactoring commits, but not interfere (or non-rework) with changes in previous commits.

Sorry :/

But I am happy if you could point me into the correct direction (for PRs in future)

@dennisdoomen
Copy link
Member

Using fixup commits and interactive squashing. See https://www.continuousimprover.com/2020/03/keep-source-control-history-clean.html

@github-actions
Copy link

github-actions bot commented Oct 10, 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

@ITaluone ITaluone requested a review from jnyrup October 11, 2023 14:43
ITaluone and others added 2 commits October 11, 2023 17:06
Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
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.

Great work!

Dennis is conferencing these days, so he's pretty occupied.
https://twitter.com/ddoomen/status/1712069826494050455

@jnyrup jnyrup mentioned this pull request Oct 11, 2023
7 tasks
Copy link
Member

@dennisdoomen dennisdoomen left a comment

Choose a reason for hiding this comment

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

Nice work. It's always hard to keep a clean PR when moving around code and fixing bugs. Becoming proficient with fixup commits and interactive rebases is a skill you wonder why you never used it before.

@dennisdoomen dennisdoomen merged commit dcd8f2a into fluentassertions:develop Oct 14, 2023
@IT-VBFK IT-VBFK mentioned this pull request Oct 14, 2023
7 tasks
@ITaluone ITaluone deleted the fix/issue-2308 branch October 14, 2023 11:26
jnyrup added a commit to jnyrup/fluentassertions that referenced this pull request Jul 14, 2024
…pectation (fluentassertions#2358)

* Handle non-generic `dictionary` subject when compared with a generic `dictionary` expectation

* Add release notes

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>

---------

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
jnyrup added a commit to jnyrup/fluentassertions that referenced this pull request Jul 14, 2024
…pectation (fluentassertions#2358)

* Handle non-generic `dictionary` subject when compared with a generic `dictionary` expectation

* Add release notes

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>

---------

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
jnyrup added a commit to jnyrup/fluentassertions that referenced this pull request Jul 14, 2024
…pectation (fluentassertions#2358)

* Handle non-generic `dictionary` subject when compared with a generic `dictionary` expectation

* Add release notes

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>

---------

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
jnyrup added a commit to jnyrup/fluentassertions that referenced this pull request Aug 18, 2024
…pectation (fluentassertions#2358)

* Handle non-generic `dictionary` subject when compared with a generic `dictionary` expectation

* Add release notes

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>

---------

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
jnyrup added a commit to jnyrup/fluentassertions that referenced this pull request Aug 18, 2024
…pectation (fluentassertions#2358)

* Handle non-generic `dictionary` subject when compared with a generic `dictionary` expectation

* Add release notes

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>

---------

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
jnyrup added a commit that referenced this pull request Sep 9, 2024
…pectation (#2358)

* Handle non-generic `dictionary` subject when compared with a generic `dictionary` expectation

* Add release notes

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>

---------

Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BeEquivalentTo cannot compare generic and non-generic dictionary
5 participants