Midas.Assertions
1.0.4
dotnet add package Midas.Assertions --version 1.0.4
NuGet\Install-Package Midas.Assertions -Version 1.0.4
<PackageReference Include="Midas.Assertions" Version="1.0.4" />
<PackageVersion Include="Midas.Assertions" Version="1.0.4" />
<PackageReference Include="Midas.Assertions" />
paket add Midas.Assertions --version 1.0.4
#r "nuget: Midas.Assertions, 1.0.4"
#:package Midas.Assertions@1.0.4
#addin nuget:?package=Midas.Assertions&version=1.0.4
#tool nuget:?package=Midas.Assertions&version=1.0.4
Midas.Assertions
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
- Replace
using FluentAssertions;withusing Midas.Assertions; - That's it. The API surface is the same.
Target Frameworks
net8.0net9.0net10.0
License
| Product | Versions 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. |
-
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.