Verify can be extended using plugins that are shipped as nuget packages.
Plugins usually manipulate a subset of the extension points of Verify.
- Comparers for comparing non-text files.
- Converters to split a target into its component parts, then verify each of those parts.
- Serializer settings
- Ordering
- Scrubbers
Plugins can have static config and/or instance based APIs
Static APIs are enabled in a ModuleInitializer of the consuming test project.
For example in Verify.Http the method VerifyHttp.Initialize() is called:
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Initialize() =>
VerifyHttp.Initialize();
}
There is a convenience API for initializing all plugins: VerifierSettings.InitializePlugins()
This API performs the following
- Scans the current assembly's directory for plugin assemblies matching
Verify.*.dll - Loads each assembly
- Try to find the type
VerifyTests.[AssemblyNameWithPeriodsRemove] - If no type exists move to the next assembly.
- If the
Initializedproperty (public static bool Initialized { get; }) is true then move to the next assembly. An exception is thrown if noInitializedproperty is found. - Invoke the
Initializemethod (public static void Initialize()) on that type. An exception is thrown if noInitializemethod is found. Optional parameters are supported.
The plugins Initialize method should throw if already Initialized and set Initialized to true:
public static void Initialize()
{
if (Initialized)
{
throw new("Already Initialized");
}
Initialized = true;
VerifierSettings.InitializePlugins is called in a ModuleInitializer of the consuming test project:
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Initialize() =>
VerifierSettings.InitializePlugins();
}
In some scenarios it may be necessary to explicitly call Initialize for some plugins. For example when order is important, or a certain plugin has some parameters on Initialize. In this case the specific plugin(s) Initialize methods can be called, then InitializePlugins can be call.
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Initialize()
{
VerifyNServiceBus.Initialize(captureLogs: true);
VerifierSettings.InitializePlugins();
}
}
- Verify.AngleSharp: Html verification utilities via AngleSharp.
- Verify.AspNetCore: Verification of AspNetCore bits.
- Verify.Aspose: Verification of documents (pdf, docx, xlsx, and pptx) via Aspose.
- Verify.Assertions: Extends Verify to allow an assertion callback. This enables using assertion libraries to interrogate during serialization.
- Verify.AustralianProtectiveMarkings: Verification of AustralianProtectiveMarkings.
- Verify.Avalonia: Verification of Avalonia UIs.
- Verify.Blazor: Verification of Blazor Component Blazor rendering.
- Verify.Bunit: Verification of Blazor Component via bunit.
- Verify.Brighter: Verification of Brighter bits.
- Verify.Cli: Command line tool for verifying files (outside of unit tests).
- Verify.CommunityToolkit.Mvvm: Verification of CommunityToolkit.Mvvm.
- Verify.Cosmos: Verification of Azure CosmosDB.
- Verify.ClosedXml: Verification of Excel documents via ClosedXml.
- Verify.CsvHelper: Verification of CSVs via CsvHelper.
- Verify.DiffPlex: Comparison of text via DiffPlex.
- Verify.Diagnostics: Verification of System.Diagnostics.Activity types.
- Verify.OpenTelemetry: Verification of OpenTelemetry types.
- Verify.DocNet: Verification of pdfs via DocNet.
- Verify.EmailPreviewServices: Verification of html emails via EmailPreviewServices.
- Verify.EntityFramework: Verification of EntityFramework bits.
- Verify.FakeItEasy: Verification of FakeItEasy bits.
- Verify.Flurl: Verification of Flurl bits.
- Verify.GraphQL: Verification of GraphQL.NET bits.
- Verify.HeadlessBrowsers: Verification of Web UIs using Playwright, Puppeteer Sharp, or Selenium.
- Verify.Http: Verification of Http bits.
- Verify.ICSharpCode.Decompiler: Comparison of assemblies and types via ICSharpCode.Decompiler.
- Verify.ImageHash: Comparison of images via ImageHash.
- Verify.ImageSharp.Compare: Verification and comparison of images via Codeuctivity.ImageSharp.Compare.
- Verify.ImageMagick: Verification and comparison of images via Magick.NET.
- Verify.ImageSharp: Verification of images via ImageSharp.
- Verify.TestableIO.System.IO.Abstractions: Verification of TestableIO.System.IO.Abstractions.
- Verify.MailMessage: Verification of MailMessage and related types.
- YellowDogMan.Verify.Marshaling: Verification of Struct Marshaling.
- Verify.MassTransit: Support for MassTransit test helpers.
- Verify.MicrosoftLogging: Verify MicrosoftLogging.
- Verify.Mockly: Verification of Mockly bits.
- Verify.MongoDB: Verification of MongoDB bits.
- Verify.Moq: Verification of Moq bits.
- Verify.NodaTime: Support for NodaTime.
- Verify.NewtonsoftJson: Support for converting Newtonsoft.Json types (JObject and JArray).
- Verify.NServiceBus: Verify NServiceBus Test Contexts.
- Verify.NSubstitute: Support for NSubstitute types.
- Verify.Nupkg: Verification of NuGet .nupkg files.
- Verify.OpenXml: Verification of Excel documents via OpenXML.
- Verify.Pandoc: Verification of documents via PandocNet.
- Verify.PdfPig: Verification of pdfs via PdfPig.
- Verify.ParametersHashing: Extends Verify to allow hashing of parameters to mitigate long file names.
- Verify.Phash: Comparison of images via Phash.
- Verify.Quibble: Comparison of objects via Quibble.
- Verify.QuestPDF: Verification of pdf documents via QuestPDF.
- Verify.RavenDb: Verification of RavenDb bits.
- Verify.SendGrid: Verification of SendGrid.
- Verify.Sep: Verification of CSVs via Sep bits.
- Verify.Serilog: Verification of Serilog bits.
- YellowDogMan.Verify.ssimulacra2: Verification and comparison of images via ssimulacra2.
- Verify.SqlServer: Verification of SqlServer bits.
- Verify.SourceGenerators: Verification of C# Source Generators.
- Verify.SystemJson: Support for converting System.Text.Json types.
- Verify.Terminal: A dotnet tool for managing Verify snapshots.
- Verify.Ulid: Enable scrubbing of Universally Unique Lexicographically Sortable Identifiers via the Ulid package.
- Verify.NUlid: Enable scrubbing of Universally Unique Lexicographically Sortable Identifiers via NUlid package.
- Verify.WinForms: Verification of WinForms UIs.
- Verify.Xamarin: Verification of Xamarin UIs.
- Verify.Xaml: Verification of Xaml UIs.
- Spectre.Verify.Extensions: Add an attribute driven file naming convention to Verify.
- Verify.Sylvan.Data.Excel: Verification of Excel documents via Sylvan.Data.Excel.
- Verify.Syncfusion: Verification of documents (pdf, docx, xlsx, and pptx) via Syncfusion File Formats.
- Verify.Wolverine:Verifiable test context for Wolverine.
- Verify.Yaml: Support for YamlDotNet types.
- Verify.ZeroLog: Verifiable test context for ZeroLog.