Masterly.BusinessRules.Testing 3.0.0

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

Masterly.BusinessRules.Testing

Test utilities for business rules: outcome coverage (which rules your tests saw both broken and passing), a boundary finder, CsCheck-backed property checks and smoke-test mutants.

This is a companion package of Masterly.BusinessRules, a composable business-rule engine for .NET.

NuGet

Install

Add it to your test project:

dotnet add package Masterly.BusinessRules.Testing
  • Target frameworks: net8.0, net10.0 (your test project must target .NET 8 or later)
  • Dependencies: Masterly.BusinessRules, CsCheck 4.9.1 on net8.0 and 5.0.0 on net10.0

Example

using Masterly.BusinessRules;
using Masterly.BusinessRules.Testing;

public sealed class OrderTotalLimitRule : BaseBusinessRule
{
    private readonly decimal _orderTotal;

    public OrderTotalLimitRule(decimal orderTotal) => _orderTotal = orderTotal;

    public override string Code => "ORDER.TOTAL_LIMIT";

    public override string Message => "The order total must not exceed 10,000.";

    public override bool IsBroken() => _orderTotal > 10_000m;
}

public static class OrderRuleCoverage
{
    public static void Run()
    {
        using RuleCoverageSession coverage = RuleCoverage.Begin();

        BusinessRuleChecker.EvaluateAll(new OrderTotalLimitRule(12_500m).WithCoverage(coverage));   // broken
        BusinessRuleChecker.EvaluateAll(new OrderTotalLimitRule(900m).WithCoverage(coverage));      // passed

        RuleCoverageReport report = coverage.Report();
        report.AssertMinimum(1.0);   // throws RuleAssertionException when a rule was never broken or never passed
    }
}

report.ToText() prints a per-rule table you can write to your test output.

Documentation

The boundary finder, property checks, mutants and the CsCheck version notes are covered in the full documentation: https://github.com/a7mdfre7at/Masterly.BusinessRules#readme

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 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
3.0.0 0 10/28/2026