Pamba.Testing 0.3.0

dotnet add package Pamba.Testing --version 0.3.0
                    
NuGet\Install-Package Pamba.Testing -Version 0.3.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="Pamba.Testing" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pamba.Testing" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Pamba.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 Pamba.Testing --version 0.3.0
                    
#r "nuget: Pamba.Testing, 0.3.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 Pamba.Testing@0.3.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=Pamba.Testing&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Pamba.Testing&version=0.3.0
                    
Install as a Cake Tool

Pamba.Testing

Test utilities for Pamba MVU programs. Calls Update, Validate, and Subscriptions in the correct sequence and returns all results for assertion.

No test framework dependency - works with xUnit, NUnit, MSTest, or any assertion library.

Install

dotnet add package Pamba.Testing

Requires: Pamba. Namespace: Pamba.Testing.

MvuTestRunner

UpdateAndValidate

Calls Update(msg, state), then Validate (if present), then Subscriptions(newState). Returns a TransitionResult containing all outputs for assertion. When Validate returns Invalid, the state reverts, commands are dropped, and CorrectionMessage is set on the result. Does not throw.

TransitionResult<AppState, Msg, Cmd, Sub> result =
    MvuTestRunner.UpdateAndValidate(program, currentState, new Msg.Increment());

Assert.Equal(1, result.State.Count);
Assert.Single(result.Commands);
Assert.IsType<Cmd.Persist>(result.Commands[0]);
Assert.Empty(result.Subscriptions);

InitAndValidate

Calls Init(), then Validate (if present), then Subscriptions(initialState).

TransitionResult<AppState, Msg, Cmd, Sub> result =
    MvuTestRunner.InitAndValidate(program);

Assert.Equal(0, result.State.Count);
Assert.Contains(result.Commands, c => c is Cmd.LoadPreferences);

TransitionResult

public sealed record TransitionResult<TState, TMsg, TCmd, TSub>(
    TState State,
    TMsg? Message,
    TMsg? CorrectionMessage,
    ImmutableArray<TCmd> Commands,
    ImmutableArray<TSub> Subscriptions);

All outputs in a single value. CorrectionMessage is non-null when the validator rejected the transition. Commands and subscriptions are indexable - use result.Commands[0], Assert.Single, Assert.Empty, or the ergonomic extension properties WasRejected, WasAccepted, HasCommands, HasSubscriptions.

MvuScenario

Fluent API for multi-step flow testing. Dispatches a sequence of messages through the program, preserving state between steps. Each step optionally accepts an assertion on the transition result.

MvuScenario.For(program)
    .Dispatch(new Msg.Start(), r =>
    {
      Assert.True(r.State.IsRunning);
      Assert.Single(r.Subscriptions);
    })
    .Dispatch(new Msg.Increment(), r => Assert.Equal(1, r.State.Count))
    .Dispatch(new Msg.Increment())
    .AssertState(s => Assert.Equal(2, s.Count));

API

Method Purpose
MvuScenario.For(program) Create a runner. Calls Init to establish starting state.
MvuScenario.For(program, assertInit) Create a runner and assert on the Init result.
.Dispatch(msg) Advance state by one message.
.Dispatch(msg, assert) Advance and assert on the TransitionResult.
.DispatchAll(msgs...) Advance by multiple messages in sequence.
.DispatchWithCorrections(msg, maxDepth) Advance and auto-process corrective messages from validation rejection.
.DispatchWithCorrections(msg, assert, max) Same with assertion on first transition.
.AssertState(assert) Assert on the current accumulated state.
.AssertHistory(assert) Assert on the full transition history.
.AssertLastTransition(assert) Assert on the most recent transition.
.State Current state after all dispatched messages.
.History Immutable array of TransitionResult entries, including Init.

All methods return the runner for chaining. History includes the Init result at index 0, followed by one entry per Dispatch call.

  • Pamba - Framework-agnostic core: contracts, dispatch loop, command/subscription infrastructure.
  • Pamba.WinUI - WinUI 3 integration with DispatcherQueue, StateProjectionBase, timer/event subscription helpers, and command debouncer.

Licence

Apache License 2.0

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.
  • net10.0

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
0.3.0 111 3/21/2026
0.2.0 106 3/20/2026
0.1.0 107 3/19/2026