Momentum.Testing
0.9.0
dotnet add package Momentum.Testing --version 0.9.0
NuGet\Install-Package Momentum.Testing -Version 0.9.0
<PackageReference Include="Momentum.Testing" Version="0.9.0" />
<PackageVersion Include="Momentum.Testing" Version="0.9.0" />
<PackageReference Include="Momentum.Testing" />
paket add Momentum.Testing --version 0.9.0
#r "nuget: Momentum.Testing, 0.9.0"
#:package Momentum.Testing@0.9.0
#addin nuget:?package=Momentum.Testing&version=0.9.0
#tool nuget:?package=Momentum.Testing&version=0.9.0
Momentum.Testing
The test harness for Momentum, an event-driven, multi-tenant workflow framework for .NET:
FlowTestHarness— auto-discovers your generated steps and cascades events through them in memory: publish an event, assert onExecutedSteps,PublishedEvents,DeadLetters- Retry/dead-letter simulation mirroring the runtime's semantics
InMemoryBus/InMemoryMomentumPublisher— capture internal and external publishesScheduledEvents/AdvanceTimeAsync— inspect deadlines and advance virtual time across API calls and handler cascades- Cron helpers — validate a step's Quartz schedule and fire it as the scheduler would
No database, broker, or application host is required; flow tests run in memory.
Install
dotnet add package Momentum.Testing
Flow test
using Momentum.Testing;
[Fact]
public async Task Published_event_runs_the_registered_handler()
{
using var harness = new FlowTestHarness(autoDiscover: false);
var handled = false;
harness.RegisterHandler<UserCreated>((evt, _) =>
{
handled = true;
return Task.CompletedTask;
});
await harness.Bus.PublishAsync(new UserCreated(Guid.NewGuid(), "user@example.com")
{
TenantId = Guid.NewGuid()
});
Assert.True(handled);
Assert.Single(harness.GetPublished<UserCreated>());
}
Auto-discovery is enabled by default and loads generated StepRegistration metadata
from referenced step assemblies. It fails loudly when no registration can be found;
assert DiscoveredHandlerCount when you want to pin the discovered topology.
The harness records executed steps, returned StepResult values, published internal
and external events, retry attempts, and simulated dead letters. Use
TriggerCronStepAsync(typeof(MyCronStep)) to validate and execute a cron definition
without starting Quartz.
Scheduled events
harness.Bus.ScheduleAsync(message, delay) queues a deadline without delivering
it immediately. Inspect harness.ScheduledEvents, then call
await harness.AdvanceTimeAsync(delay) to execute due handlers without sleeping.
The same virtual clock is shared across API calls and handler cascades, including
retry simulation. PostgreSQL integration tests are still needed to verify business
transaction rollback and durable recovery.
License
Momentum is free for qualifying non-commercial open-source projects. Commercial use requires a separate written license agreement. The complete terms are included in the package.
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.10)
- Microsoft.Extensions.Logging (>= 10.0.10)
- Momentum.Abstractions (>= 0.9.0)
- Quartz (>= 3.19.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.