FlowLite.Testing 8.0.0

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

FlowLite.Testing

FlowLite.Testing is a minimalistic and fluent testing library designed for writing expressive and structured unit tests for your FlowLite FSM workflows. It builds on top of FlowLite, enabling easy assertions for:

  • State transitions
  • Entity lifecycle
  • Log messages
  • Transition history
  • Entity deletion

Features

  • Fluent Assertions — expressive .Should().Allow(...), .BeIn(...), .Logs(), etc.
  • Trigger Validation.Assert().Allow(...) or .NotAllow(...).
  • Entity Validation — validate entity changes or deletions via .HaveEntity(...) and .DeleteEntity().
  • Log Inspection — assert warnings, errors, or specific messages.
  • History Validation — verify transition path, length, or contents.
  • Minimal & Fast — no dependencies on other testing libraries or frameworks.
  • Designed for full compatibility with FlowLite FSM.

Installation

To install the latest version of the FlowLite.Testing NuGet package:

NuGet Package Manager

Install-Package FlowLite.Testing -Version 8.0.0

.NET CLI

dotnet add package FlowLite.Abstractions --version 8.0.0
dotnet add package FlowLite.Testing --version 8.0.0

Usage Guide

Required Namespaces

using FlowLite.Testing;
using FlowLite.Testing.Assertions;

Fluent Testing API

1. Assert a Trigger is Allowed or Rejected

fsm.Should().Allow(OrderTrigger.Pay);
fsm.Should().NotAllow(OrderTrigger.Cancel);

2. Verify Current State

fsm.Should().BeIn(OrderState.Paid);

3. Entity Assertions

fsm.Should().NotNullEntity();
fsm.Should().HaveEntity(order =>
{
    Assert.Equal("Shipped", order?.Status);
});

4. Log Assertions

fsm.Should().Logs().Log(LogLevel.Warning, "invalid transition");
fsm.Should().Logs().BeFinalState();
fsm.Should().Logs().ContainFinalStateLog();
fsm.Should().Logs().MatchSnapshot(new[] { "FSM initialized", "Transitioned to Paid" });

5. History Assertions

fsm.Should().History()
    .StartWith(OrderState.Created)
    .HaveInHistory(OrderState.Created, OrderState.Paid, OrderState.Shipped)
    .Contains(OrderTrigger.Pay, OrderState.Paid)
    .HaveLength(3)
    .ContainsTrigger(OrderTrigger.Ship);

Trigger-Only Assertions

You can use .Assert() style for concise checks:

fsm.Assert().Allow(OrderTrigger.Pay);
fsm.Assert().NotAllow(OrderTrigger.Cancel);

Minimal sample

fsm.AddTransition(OrderState.Created, OrderTrigger.Pay, OrderState.Paid, async (_, ctx) =>
   {
       ctx.Entity!.Status = "Paid";
       await Task.CompletedTask;
   });
await fsm.FireAsync(OrderTrigger.Pay);
fsm.Should()
    .BeIn(OrderState.Paid)
    .NotNullEntity()
    .Logs().Log(LogLevel.Info, "Paid");

License

This project is licensed under the MIT License.

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 was computed.  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 was computed.  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
8.0.0 182 4/20/2025

- Added support for .NET 8.0;