FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

VerifyTests/Verify.Ulid: Extends Verify to enable scrubbing of Universally Unique Lexicographically Sortable Identifiers via Ulid the https://github.com/Cysharp/Ulid package · GitHub

Repository files navigation

Verify.Ulid

Extends Verify to enable scrubbing of Universally Unique Lexicographically Sortable Identifiers via Ulid package.

See Milestones for release notes.

Sponsors

Entity Framework Extensions

Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.

Developed using JetBrains IDEs

NuGet

Usage

Call VerifyUlid.Initialize() once at assembly load time.

[ModuleInitializer]
public static void Init() =>
    VerifyUlid.Initialize();

snippet source | anchor

ULIDs will then be scrubbed:

[Test]
public Task UlidScrubbing()
{
    var id = Ulid.NewUlid();
    var target = new Person
    {
        Id = id,
        Name = "Sarah",
        Description = $"Sarah ({id})"
    };
    return Verify(target);
}

snippet source | anchor

Result:

{
  Id: Ulid_1,
  Name: Sarah,
  Description: Sarah (Ulid_1)
}

snippet source | anchor

Disabling Scrubbing

To disable scrubbing use DontScrubUlids()

[Test]
public Task DontScrubFluent()
{
    var id = Ulid.Parse("01JGXG0GDGQEP47CBQ65E50HYH");
    var target = new Person
    {
        Id = id,
        Name = "Sarah",
        Description = $"Sarah ({id})"
    };
    return Verify(target)
        .DontScrubUlids();
}

[Test]
public Task DontScrubInstance()
{
    var id = Ulid.Parse("01JGXG0GDGQEP47CBQ65E50HYH");
    var target = new Person
    {
        Id = id,
        Name = "Sarah",
        Description = $"Sarah ({id})"
    };
    var settings = new VerifySettings();
    settings.DontScrubUlids();
    return Verify(target, settings);
}

snippet source | anchor

Result:

{
  Id: 01JGXG0GDGQEP47CBQ65E50HYH,
  Name: Sarah,
  Description: Sarah (01JGXG0GDGQEP47CBQ65E50HYH)
}

snippet source | anchor

Icon

Pattern designed by Mohamed Salah Hajji from The Noun Project.

About

Extends Verify to enable scrubbing of Universally Unique Lexicographically Sortable Identifiers via Ulid the https://github.com/Cysharp/Ulid package

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages


Back | FazBrowse Home | New Git URL