AsiBackbone.Testing 3.2.1

dotnet add package AsiBackbone.Testing --version 3.2.1
                    
NuGet\Install-Package AsiBackbone.Testing -Version 3.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AsiBackbone.Testing" Version="3.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AsiBackbone.Testing" Version="3.2.1" />
                    
Directory.Packages.props
<PackageReference Include="AsiBackbone.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AsiBackbone.Testing --version 3.2.1
                    
#r "nuget: AsiBackbone.Testing, 3.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AsiBackbone.Testing@3.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AsiBackbone.Testing&version=3.2.1
                    
Install as a Cake Addin
#tool nuget:?package=AsiBackbone.Testing&version=3.2.1
                    
Install as a Cake Tool

AsiBackbone.Testing

AsiBackbone.Testing provides test harness helpers for exercising AsiBackbone-governed endpoints and services without forcing host applications to wire production persistence, signing, outbox, audit, or capability-grant infrastructure in every automated test.

This package is for tests only. It is not a production enforcement provider and should not be used to weaken host-owned governance, persistence, signing, audit, or capability validation in production applications.

What it registers

AddAsiBackboneTestHarness(...) registers deterministic test-only substitutions for common host-owned seams:

  • IAsiBackbonePolicyEvaluator<AsiBackboneConstraintEvaluationContext>
  • IAsiBackboneEndpointCapabilityGrantValidator
  • IAsiBackboneAuditSink backed by AsiBackboneTestAuditSink
  • IAsiBackboneGovernanceOutboxStore backed by the non-durable in-memory outbox store
  • IAsiBackboneSigningService backed by a deterministic no-signature service

The package does not change production package defaults. ASP.NET Core endpoint governance remains fail-closed when host-owned services are missing unless tests explicitly register this harness.

Basic endpoint test setup

using AsiBackbone.AspNetCore.DependencyInjection;
using AsiBackbone.Testing;

builder.Services
    .AddAsiBackboneAspNetCore()
    .AddAsiBackboneTestHarness(harness =>
    {
        harness.AllowAllPolicies();
        harness.AllowCapabilityGrants();
    });

Deterministic policy results

builder.Services.AddAsiBackboneTestHarness(harness =>
{
    harness.AllowAllPolicies();
    harness.SetPolicyResult<MyStrictPolicy>(
        GovernanceDecision.Deny("test.denied", "Denied by test harness."));
});

For stricter tests, require every policy marker to have an explicit result:

builder.Services.AddAsiBackboneTestHarness(harness =>
{
    harness.RequirePolicyResult<MyStrictPolicy>(GovernanceDecision.Allow());
});

When RequirePolicyResult<TPolicy>(...) is used and the selected endpoint has an unconfigured policy marker, the harness returns a deterministic denied decision with reason code test_harness.policy_result.missing.

Inspecting audit residue

AsiBackboneTestAuditSink auditSink = services.GetRequiredService<AsiBackboneTestAuditSink>();

Assert.Single(auditSink.Entries);

The audit sink is in-memory and process-local. It is intended for assertion-friendly automated tests, not durable records or tamper-evidence.

Reusable contract fixtures

AsiBackbone.Testing.Contracts contains framework-neutral contract fixtures and assertions for extension authors. The helpers throw AsiBackboneContractViolationException instead of depending on xUnit, NUnit, or MSTest directly, so test projects can reuse the same safe-collapse invariants from any test runner.

Available fixtures include:

  • AsiBackbonePolicyEvaluatorContract<TContext>
  • AsiBackboneDecisionPolicyContract<TContext>
  • AsiBackboneConstraintContract<TContext>
  • AsiBackboneEndpointCapabilityGrantValidatorContract
  • AsiBackboneAuditSinkContract
  • AsiBackboneDecisionContract assertion helpers

Example xUnit usage for a custom policy evaluator:

using AsiBackbone.Core.Constraints;
using AsiBackbone.Core.Evaluation;
using AsiBackbone.Testing.Contracts;
using Xunit;

public sealed class MyPolicyEvaluatorContractTests
{
    [Fact]
    public async Task Evaluator_returns_safe_decision()
    {
        var contract = new MyPolicyEvaluatorContract();

        await contract.VerifyEvaluatorReturnsSafeDecisionAsync(TestContext.Current.CancellationToken);
    }

    private sealed class MyPolicyEvaluatorContract
        : AsiBackbonePolicyEvaluatorContract<AsiBackboneConstraintEvaluationContext>
    {
        protected override IAsiBackbonePolicyEvaluator<AsiBackboneConstraintEvaluationContext> CreateEvaluator()
        {
            return new MyPolicyEvaluator();
        }

        protected override AsiBackboneConstraintEvaluationContext CreateEvaluationContext()
        {
            return new AsiBackboneConstraintEvaluationContext(
                correlationId: "contract-correlation",
                policyVersion: "policy-v1",
                policyHash: "policy-hash");
        }
    }
}

The default contract assertions verify portable invariants such as non-null decisions, reason codes for denied/deferred/acknowledgment/escalation paths, correlation propagation, policy telemetry presence when supplied or resolved by the implementation, invalid capability-grant scenarios not returning Allow, and valid audit residue shape.

WebApplicationFactory-style usage

factory.WithWebHostBuilder(builder =>
{
    builder.ConfigureServices(services =>
    {
        services.AddAsiBackboneTestHarness(harness =>
        {
            harness.AllowAllPolicies();
            harness.AllowCapabilityGrants();
        });
    });
});

Use this pattern when a host application already calls AddAsiBackboneAspNetCore() and exposes endpoints with metadata such as .RequireGovernancePolicy<TPolicy>(), .RequireCapabilityGrant(...), or .EmitGovernanceAudit().

Production boundary

This package is intentionally scoped to automated tests, samples, and local developer validation. Production applications should register real policy evaluators, capability validators, audit sinks, durable outbox stores, signing providers, and storage providers appropriate to their risk profile.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2.1 100 8/7/2026
3.2.0 108 8/2/2026
3.1.0 97 7/20/2026
3.0.1 107 7/14/2026
3.0.0 129 7/13/2026 3.0.0 is deprecated.
2.3.0 107 7/6/2026
2.2.1 114 7/3/2026
2.2.0 119 7/1/2026
2.1.1 112 6/29/2026
2.1.0 109 6/28/2026
2.0.2 148 6/26/2026
2.0.1 117 6/26/2026
2.0.0 121 6/25/2026