BackWave.Testing
1.1.1
See the version list below for details.
dotnet add package BackWave.Testing --version 1.1.1
NuGet\Install-Package BackWave.Testing -Version 1.1.1
<PackageReference Include="BackWave.Testing" Version="1.1.1" />
<PackageVersion Include="BackWave.Testing" Version="1.1.1" />
<PackageReference Include="BackWave.Testing" />
paket add BackWave.Testing --version 1.1.1
#r "nuget: BackWave.Testing, 1.1.1"
#:package BackWave.Testing@1.1.1
#addin nuget:?package=BackWave.Testing&version=1.1.1
#tool nuget:?package=BackWave.Testing&version=1.1.1
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;
AdvanceAsyncstops there and runs it. Assertjob.Attemptafterwards. - Recurring Schedules:
UpsertRecurringAsync("nightly", Cron.Daily(3), template)thenAdvanceAsync(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 | Versions 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. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release notes and upgrade guidance: https://backwave.app/