Rule pack test kit · .NET NuGet
InvoiceLint.Testing
Prove a rule pack matches its catalog and that mutations fire the expected rule IDs.
Install
dotnet add package InvoiceLint.Testing --version 0.1.0-dev.2
Targets net8.0 and net10.0. Depends on InvoiceLint.Core. MIT. Use from test projects.
Catalog checks
using InvoiceLint.Testing;
IReadOnlyList<string> problems = RulePackChecks.Verify(
MyRulePack.Instance,
typeof(MyRulePack).Assembly);
Empty list means Implemented catalog ids match rule classes and the pack Rules list.
Mutations
using System.Xml.Linq;
using InvoiceLint;
using InvoiceLint.Testing;
var mutation = new Mutation("drop-flag", "toy-flag", doc =>
{
doc.Root!.Element(doc.Root.Name.Namespace + "Flag")?.Remove();
});
XDocument mutated = MutationRunner.Apply(baseDocument, mutation);
ValidationResult result = Validator.Validate(mutated, MyRulePack.Instance);
Related
- InvoiceLint.Core — rule engine
- AeInvoice — UAE PINT AE pack
License
MIT.
FAQ — InvoiceLint.Testing
What is InvoiceLint.Testing? +
InvoiceLint.Testing is a MIT test kit for InvoiceLint rule packs. RulePackChecks.Verify compares catalog ids to rule classes; MutationRunner clones XML and applies named mutations.
How do I install InvoiceLint.Testing? +
From a test project run: dotnet add package InvoiceLint.Testing --version 0.1.0-dev.2. It targets .NET 8 and .NET 10 and depends on InvoiceLint.Core.
What does RulePackChecks.Verify do? +
It reports problems when Implemented catalog ids lack a rule class or pack registration, when registered rules are missing from the catalog, or when rule ids are duplicated.
Where is the NuGet package? +
https://www.nuget.org/packages/InvoiceLint.Testing/ — install from nuget.org; public how-to lives on this page and the linked GitHub gist.