Handle comparing an `IDictionary` subject with an `IDictionary<,>` expectation by ITaluone · Pull Request #2358 · fluentassertions/fluentassertions · GitHub
Skip to content

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

Merged
dennisdoomen merged 2 commits into
fluentassertions:developfrom
ITaluone:fix/issue-2308
Oct 14, 2023
Merged

Handle comparing an IDictionary subject with an IDictionary<,> expectation#2358
dennisdoomen merged 2 commits into
fluentassertions:developfrom
ITaluone:fix/issue-2308

Conversation

@ITaluone

@ITaluone ITaluone commented Oct 3, 2023

Copy link
Copy Markdown
Contributor

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

github-actions Bot commented Oct 3, 2023

Copy link
Copy Markdown

@ITaluone

ITaluone commented Oct 3, 2023

Copy link
Copy Markdown
Contributor Author

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

coveralls commented Oct 3, 2023

Copy link
Copy Markdown

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

Comment thread Src/FluentAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs Outdated
@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

dennisdoomen commented Oct 8, 2023

Copy link
Copy Markdown
Member

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.

Comment thread Src/FluentAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs Outdated
Comment thread Src/FluentAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs Outdated
Comment thread Src/FluentAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs Outdated
Comment thread Src/FluentAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs Outdated
@IT-VBFK

IT-VBFK commented Oct 8, 2023

Copy link
Copy Markdown
Contributor

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

ITaluone commented Oct 8, 2023

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Member

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

Comment thread docs/_pages/releases.md Outdated
Comment thread Src/FluentAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs Outdated
Comment thread Src/FluentAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs Outdated
Comment thread Src/FluentAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs Outdated
@github-actions

github-actions Bot commented Oct 10, 2023

Copy link
Copy Markdown

@ITaluone ITaluone requested a review from jnyrup October 11, 2023 14:43
Comment thread Tests/FluentAssertions.Equivalency.Specs/DictionarySpecs.cs Outdated
Comment thread Tests/FluentAssertions.Equivalency.Specs/DictionarySpecs.cs Outdated
Comment thread Tests/FluentAssertions.Equivalency.Specs/DictionarySpecs.cs Outdated
ITaluone and others added 2 commits October 11, 2023 17:06
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