{"id":18937406,"url":"https://github.com/verifytests/verify.assertions","last_synced_at":"2026-02-27T02:33:31.012Z","repository":{"id":250672060,"uuid":"834723753","full_name":"VerifyTests/Verify.Assertions","owner":"VerifyTests","description":"Extends Verify to allow an assertion callbacks","archived":false,"fork":false,"pushed_at":"2024-12-20T22:40:39.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-22T18:40:12.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VerifyTests.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"VerifyTests"}},"created_at":"2024-07-28T06:54:37.000Z","updated_at":"2024-12-20T22:40:44.000Z","dependencies_parsed_at":"2024-10-26T02:49:08.271Z","dependency_job_id":null,"html_url":"https://github.com/VerifyTests/Verify.Assertions","commit_stats":null,"previous_names":["verifytests/verify.assertions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.Assertions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.Assertions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.Assertions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.Assertions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VerifyTests","download_url":"https://codeload.github.com/VerifyTests/Verify.Assertions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232032040,"owners_count":18462966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T12:11:03.180Z","updated_at":"2026-02-27T02:33:30.973Z","avatar_url":"https://github.com/VerifyTests.png","language":"C#","funding_links":["https://github.com/sponsors/VerifyTests"],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"/src/icon.png\" height=\"30px\"\u003e Verify.Assertions\n\n[![Discussions](https://img.shields.io/badge/Verify-Discussions-yellow?svg=true\u0026label=)](https://github.com/orgs/VerifyTests/discussions)\n[![Build status](https://ci.appveyor.com/api/projects/status/6stx39bhogfbgnpi?svg=true)](https://ci.appveyor.com/project/SimonCropp/Verify-Assertions)\n[![NuGet Status](https://img.shields.io/nuget/v/Verify.Assertions.svg)](https://www.nuget.org/packages/Verify.Assertions/)\n\nExtends [Verify](https://github.com/VerifyTests/Verify) to allow assertion callbacks. This enables using assertion libraries to interrogate during serialization. The primary use case for this is when the data structures being verified are either complex or large.\n\n**See [Milestones](../../milestones?state=closed) for release notes.**\n\n## NuGet package\n\nhttps://nuget.org/packages/Verify.Assertions/\n\n\n## Enable\n\n\u003c!-- snippet: enable --\u003e\n\u003ca id='snippet-enable'\u003e\u003c/a\u003e\n```cs\n[ModuleInitializer]\npublic static void Init() =\u003e\n    VerifyAssertions.Initialize();\n```\n\u003csup\u003e\u003ca href='/src/Tests/ModuleInitializer.cs#L3-L9' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-enable' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Usage\n\nOnce enable, any assertion library can be used.\n\nThe below examples are simplistic for illustrating the usage. In a real world scenario, if data structures being verified are small, then the assertion can happen before or after the the Verify with no need to assert during serialization.\n\n\n### [Xunit](https://xunit.net/)\n\n\u003c!-- snippet: XunitUsage --\u003e\n\u003ca id='snippet-XunitUsage'\u003e\u003c/a\u003e\n```cs\n[Fact]\npublic async Task XunitUsage()\n{\n    var nested = new Nested(Property: \"value\");\n    var target = new Target(nested);\n    await Verify(target)\n        .Assert\u003cNested\u003e(\n            _ =\u003e Assert.Equal(\"value\", _.Property));\n}\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L3-L15' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-XunitUsage' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### [NUnit](https://docs.nunit.org/articles/nunit/writing-tests/assertions/assertions.html)\n\n\u003c!-- snippet: NUnitUsage --\u003e\n\u003ca id='snippet-NUnitUsage'\u003e\u003c/a\u003e\n```cs\n[Test]\npublic async Task NUnitUsage()\n{\n    var nested = new Nested(Property: \"value\");\n    var target = new Target(nested);\n    await Verify(target)\n        .Assert\u003cNested\u003e(\n            _ =\u003e Assert.That(_.Property, Is.EqualTo(\"value\")));\n}\n```\n\u003csup\u003e\u003ca href='/src/NUnitTests/Tests.cs#L4-L16' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-NUnitUsage' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### [FluentAssertions](https://fluentassertions.com/)\n\n\u003c!-- snippet: FluentAssertionsUsage --\u003e\n\u003ca id='snippet-FluentAssertionsUsage'\u003e\u003c/a\u003e\n```cs\n[Fact]\npublic async Task FluentAssertionsUsage()\n{\n    var nested = new Nested(Property: \"value\");\n    var target = new Target(nested);\n    await Verify(target)\n        .Assert\u003cNested\u003e(\n            _ =\u003e _.Property.Should().Be(\"value\"));\n}\n```\n\u003csup\u003e\u003ca href='/src/Tests/FluentAssertionsTests.cs#L5-L17' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-FluentAssertionsUsage' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### [Shouldly](https://github.com/shouldly/shouldly)\n\n\u003c!-- snippet: ShouldlyUsage --\u003e\n\u003ca id='snippet-ShouldlyUsage'\u003e\u003c/a\u003e\n```cs\n[Fact]\npublic async Task ShouldlyUsage()\n{\n    var nested = new Nested(Property: \"value\");\n    var target = new Target(nested);\n    await Verify(target)\n        .Assert\u003cNested\u003e(\n            _ =\u003e _.Property.ShouldBe(\"value\"));\n}\n```\n\u003csup\u003e\u003ca href='/src/Tests/ShouldyAssertionsTests.cs#L5-L17' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-ShouldlyUsage' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Shared Assertions\n\nAssertions can be added globally.\n\n\u003c!-- snippet: Shared --\u003e\n\u003ca id='snippet-Shared'\u003e\u003c/a\u003e\n```cs\n[ModuleInitializer]\npublic static void AddSharedAssert() =\u003e\n    VerifyAssertions\n        .Assert\u003cSharedNested\u003e(\n            _ =\u003e Assert.Equal(\"value\", _.Property));\n\n[Fact]\npublic async Task SharedAssert()\n{\n    var nested = new SharedNested(Property: \"value\");\n    var target = new SharedTarget(nested);\n    await Verify(target);\n}\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L17-L33' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Shared' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Icon\n\n[Approval](https://thenounproject.com/term/correct/6480102/) designed by [Danang Marhendra](https://thenounproject.com/creator/masart/) from [The Noun Project](https://thenounproject.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverifytests%2Fverify.assertions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fverifytests%2Fverify.assertions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverifytests%2Fverify.assertions/lists"}