BackWave.Testing 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BackWave.Testing --version 1.1.0
                    
NuGet\Install-Package BackWave.Testing -Version 1.1.0
                    
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="BackWave.Testing" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BackWave.Testing" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="BackWave.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 BackWave.Testing --version 1.1.0
                    
#r "nuget: BackWave.Testing, 1.1.0"
                    
#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 BackWave.Testing@1.1.0
                    
#: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=BackWave.Testing&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=BackWave.Testing&version=1.1.0
                    
Install as a Cake Tool

BackWave.Testing

Deterministic tests for your real jobs: the In-Memory Store plus Virtual Time behind one harness. Enqueue real jobs, advance the clock, and assert through the same Monitor API the dashboard uses. Every due instant — mints, retries, Lease expiries, Continuations — is processed synchronously and in order. A year of cron behavior tests in milliseconds and never flakes in CI.

The full pattern: define, enqueue, advance, assert

// 1. Define the job — the same record and handler your app ships.
[Job("send-invoice")]
public sealed record SendInvoice(string OrderId);

public sealed class SendInvoiceHandler(IInvoiceGateway gateway) : IJobHandler<SendInvoice>
{
    public Task HandleAsync(SendInvoice job, JobContext context, CancellationToken cancellationToken)
        => gateway.SendAsync(job.OrderId, cancellationToken);
}

[Fact]
public async Task InvoiceGoesOut_TwoDaysAfterTheOrder()
{
    // 2. Build the harness from your registry and DI services.
    var services = new ServiceCollection()
        .AddSingleton<IInvoiceGateway, FakeInvoiceGateway>()
        .AddTransient<IJobHandler<SendInvoice>, SendInvoiceHandler>()
        .BuildServiceProvider();
    var harness = new BackWaveHarness(BackWaveJobs.CreateRegistry(), services);

    // 3. Enqueue and advance Virtual Time — "advance 3 days" runs everything due in between.
    var jobId = await harness.EnqueueAsync(new SendInvoice("order-42"), delay: TimeSpan.FromDays(2));
    await harness.AdvanceAsync(TimeSpan.FromDays(3));

    // 4. Assert through the Monitor API — the same surface production observability uses.
    var job = await harness.Monitor.GetJobAsync(jobId);
    Assert.Equal(JobState.Succeeded, job!.State);
}

What the harness covers

  • Retries: a failing Attempt reschedules at its backoff instant; AdvanceAsync stops there and runs it. Assert job.Attempt afterwards.
  • Recurring Schedules: UpsertRecurringAsync("nightly", Cron.Daily(3), template) then AdvanceAsync(TimeSpan.FromDays(365)) mints and runs a year of ticks in milliseconds.
  • Continuations: EnqueueContinuationAsync(receipt, parentId) releases when the parent goes terminal during an advance.
  • Transactional Enqueue: harness.BeginTransaction() honors the rollback-means-it-never- existed guarantee, so outbox-replacement code paths are testable:
using (var transaction = harness.BeginTransaction())
{
    await harness.EnqueueAsync(new SendInvoice("order-43"), transaction: transaction);
    transaction.Rollback(); // the job never existed — not claimable, not visible
}
  • Job Manifest: commit JobManifest.Verify(registry, "jobs.manifest") in a test and a removed or renamed Wire Name fails in PR review instead of quarantining in production.

Determinism rules

Virtual Time starts at a fixed instant (configurable via BackWaveHarnessOptions.StartTime) and only moves when you advance it. No wall clock, no sleeps, no polling — the same test input always produces the same execution order.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
1.2.0 0 7/12/2026
1.1.1 47 7/10/2026
1.1.0 100 7/6/2026
1.0.0 94 7/6/2026

Release notes and upgrade guidance: https://backwave.app/