Skip to content

Sanitize or Count custom members #1149

Answered by SimonCropp
hahn-kev asked this question in Q&A
Discussion options

You must be logged in to vote

there is no built in feature to achieve this. but your could leverage MemberConverter https://github.com/VerifyTests/Verify/blob/main/docs/serializer-settings.md#converting-a-member

public class CounterTarget
{
    public string? Property1 { get; set; }
    public string? Property2 { get; set; }
    public string? Property3 { get; set; }
}

public class CustomCounterTests
{
    static AsyncLocal<List<string>?> local = new();

    [ModuleInitializer]
    public static void CounterInit()
    {
        VerifierSettings.OnVerify(
            before: () => local.Value = new(),
            after: () => local.Value = null
        );

        AddCountConverter<CounterTarget>( _ => _.Property1);
 …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hahn-kev
Comment options

@mattiasnordqvist
Comment options

@hahn-kev
Comment options

@mattiasnordqvist
Comment options

Answer selected by hahn-kev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants