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

feat: added custom counter comparers #1297

Closed

Conversation

JaktensTid
Copy link

@JaktensTid JaktensTid commented Sep 17, 2024

Ability to add custom comparers to Counter

private class StubGuidComparer : IEqualityComparer<Guid>
    {
        public bool Equals(Guid x, Guid y) => true;

        public int GetHashCode(Guid obj) => 1;
    }

    [Fact]
    public async Task ShouldInjectCustomGuidComparer()
    {
        var obj = new
        {
            Item1 = Guid.NewGuid(),
            Item2 = Guid.NewGuid(),
            Item3 = Guid.NewGuid()
        };

        var settings = new VerifySettings();
        settings.ReplaceScrubberGuidComparer(new StubGuidComparer());
        await Verify(obj, settings: settings);
    }

This test case will produce the following .verified.txt file

{
  Item1: Guid_1,
  Item2: Guid_1,
  Item3: Guid_1
}

@JaktensTid
Copy link
Author

@dotnet-policy-service agree

@SimonCropp
Copy link
Member

can u explain why?

@JaktensTid
Copy link
Author

@SimonCropp #1285

@SimonCropp
Copy link
Member

can u add some documentation that explains the use case with your datetime scenario

@JaktensTid
Copy link
Author

@SimonCropp added

@SimonCropp
Copy link
Member

do you need this to be a "per test" based feature? or would a static setting suffice?

@JaktensTid
Copy link
Author

do you need this to be a "per test" based feature? or would a static setting suffice?

Hi, it's more static setting

@JaktensTid
Copy link
Author

@SimonCropp if there is ability to add it 'dynamic' let me know

@SimonCropp
Copy link
Member

in that case how about you convert this PR to only be a static setting.

then i will merge and release it

@JaktensTid
Copy link
Author

@SimonCropp you mean just make these settings 'static'?

@SimonCropp SimonCropp closed this Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants