Midas.Assertions 1.0.4

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

Midas.Assertions

NuGet NuGet Downloads License: MIT Buy Me a Coffee Sponsor

Zero-dependency fluent assertion library for .NET. Drop-in replacement for FluentAssertions with a familiar Should().Be() API.
Built by Midas Path Software Solutions — no commercial licensing, no telemetry, no surprises.


Why Midas.Assertions?

FluentAssertions introduced a commercial license requirement starting with v8. Rather than pay per-developer fees or freeze on an old version, we built our own — same fluent API, zero dependencies, MIT-licensed forever.

The result: 166 tests passing, covering the full assertion surface we actually use in production. If Should().Be() works in FluentAssertions, it works identically here.


Installation

dotnet add package Midas.Assertions

Quick Start

using Midas.Assertions;

// Object assertions
result.Should().NotBeNull();
result.Should().Be(expected);
result.Should().BeOfType<PatientDto>();

// String assertions
name.Should().NotBeNullOrWhiteSpace();
name.Should().StartWith("Dr.");
name.Should().Contain("Smith");
name.Should().MatchWildcard("Dr.*Smith*");

// Numeric assertions
age.Should().BeGreaterThan(0);
balance.Should().BeInRange(0, 1000);
temperature.Should().BeApproximately(98.6, 0.5);

// Boolean assertions
isActive.Should().BeTrue();
isDeleted.Should().BeFalse();

// DateTime assertions
createdAt.Should().BeBefore(DateTime.UtcNow);
expiresAt.Should().BeAfter(DateTime.UtcNow);
scheduledAt.Should().BeCloseTo(expected, TimeSpan.FromSeconds(1));

// Collection assertions
patients.Should().NotBeEmpty();
patients.Should().HaveCount(5);
patients.Should().Contain(p => p.Name == "Kwame");
callOrder.Should().ContainInOrder("save", "notify", "log");
tags.Should().OnlyHaveUniqueItems();

// Exception assertions (sync)
action.Should().Invoking(a => a.Execute())
    .Should().Throw<InvalidOperationException>()
    .WithMessage("*not allowed*");

// Exception assertions (async)
await func.Should().Invoking(f => f.ExecuteAsync())
    .Should().ThrowAsync<UnauthorizedAccessException>()
    .WithMessage("*expired*");

Assertion Classes

Class Covers
ObjectAssertions Be, NotBe, BeNull, NotBeNull, BeSameAs, BeOfType<T>, BeAssignableTo<T>
StringAssertions Be, Contain, StartWith, EndWith, MatchWildcard, MatchRegex, BeNullOrEmpty, BeNullOrWhiteSpace
NumericAssertions Be, BeGreaterThan, BeLessThan, BeInRange, BePositive, BeNegative, BeApproximately
BooleanAssertions BeTrue, BeFalse, Be
DateTimeAssertions Be, BeBefore, BeAfter, BeOnOrBefore, BeOnOrAfter, BeCloseTo
CollectionAssertions BeEmpty, HaveCount, Contain, ContainInOrder, OnlyHaveUniqueItems, AllSatisfy, SatisfyRespectively, BeEquivalentTo
ActionAssertions Throw<T>, NotThrow
FunctionAssertions Throw<T>, NotThrow
AsyncFunctionAssertions ThrowAsync<T>, NotThrowAsync
ExceptionAssertions WithMessage, WithInnerException, WithParameterName

Fluent Chaining

All assertions return AndConstraint<T> so you can chain:

name.Should()
    .NotBeNull()
    .And.StartWith("Dr.")
    .And.HaveLength(expected.Length);

Exception assertions return ExceptionAssertions<T> for further checks:

act.Should().Throw<ArgumentException>()
    .WithMessage("*cannot be null*")
    .WithParameterName("patientId");

Cross-Numeric Comparisons

ObjectAssertions.Be() handles cross-numeric types automatically — uint.Should().Be(10) works even though uint and int are different types when boxed.


Migration from FluentAssertions

  1. Replace using FluentAssertions; with using Midas.Assertions;
  2. That's it. The API surface is the same.

Target Frameworks

  • net8.0
  • net9.0
  • net10.0

License

MIT © Midas Path Software Solutions

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

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
1.0.4 27 4/4/2026
1.0.2 89 3/11/2026
1.0.1 84 3/11/2026