Jeninnet.Assertions
1.0.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
Requires NuGet 7.3.0 or higher.
dotnet add package Jeninnet.Assertions --version 1.0.0
NuGet\Install-Package Jeninnet.Assertions -Version 1.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="Jeninnet.Assertions" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jeninnet.Assertions" Version="1.0.0" />
<PackageReference Include="Jeninnet.Assertions" />
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 Jeninnet.Assertions --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jeninnet.Assertions, 1.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 Jeninnet.Assertions@1.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=Jeninnet.Assertions&version=1.0.0
#tool nuget:?package=Jeninnet.Assertions&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Jeninnet.Assertions
A fluent, framework-agnostic assertion library for .NET tests, providing expressive validation for objects, strings, collections, exceptions, async operations, and IO test infrastructure.
Design Philosophy
- Framework-agnostic — No dependency on MSTest, xUnit, or NUnit. Works with any test framework.
- Fluent API — Intuitive
Should().*chain starting from any value. - Discoverable — Extension methods on core types (
bool,string,IEnumerable<T>,Action,Func<Task>). - Descriptive — Clear failure messages without custom assertion formatters.
- Extensible — Add new assertion types by implementing the same pattern.
- Self-contained — No external assertion library dependencies.
Installation
dotnet add package Jeninnet.Assertions
Supported Frameworks
- .NET 10.0+
- Works with MSTest, xUnit, NUnit, and any other .NET test framework
Usage
using Jeninnet.Assertions;
Boolean Assertions
true.Should().BeTrue();
false.Should().BeFalse();
String Assertions
"hello".Should().Be("hello");
"hello world".Should().Contain("world");
"readme.md".Should().EndsWith(".md");
string? nullStr = null;
nullStr.Should().BeNull();
"text".Should().NotBeNull();
Collection Assertions
var items = new[] { 1, 2, 3 };
items.Should().HaveCount(3);
items.Should().BeEmpty();
items.Should().NotBeEmpty();
items.Should().Contain(2);
items.Should().NotContain(4);
items.Should().Contain(x => x > 2);
items.Should().NotContain(x => x > 5);
items.Should().BeEquivalentTo(new[] { 3, 1, 2 });
items.Should().ContainSubset(new[] { 1, 3 });
var single = items.Should().ContainSingle();
single.Which.Should().Be(1);
var matching = items.Should().ContainSingle(x => x > 2);
matching.Which.Should().Be(3);
Exception Assertions
// Synchronous
Action act = () => { throw new InvalidOperationException("test"); };
act.Should().Throw<InvalidOperationException>()
.Exception.Should().NotBeNull();
// With message check
act.Should().Throw<InvalidOperationException>("Expected InvalidOperationException");
// Completing without throwing
Action ok = () => { };
ok.Should().NotThrow();
ok.Should().NotThrow("Optional failure message");
// Async
Func<Task> asyncAct = async () => { await Task.Delay(1); throw new TimeoutException(); };
await asyncAct.Should().ThrowAsync<TimeoutException>();
// Async completing without throwing
Func<Task> asyncOk = () => Task.CompletedTask;
await asyncOk.Should().NotThrowAsync();
Object Assertions
object? obj = "hello";
obj.Should().Be("hello");
obj.Should().NotBeNull();
obj.Should().BeOfType<string>();
object? nullObj = null;
nullObj.Should().BeNull();
Test Environment (IO)
using Jeninnet.Assertions.IO;
using var env = new TestEnvironment();
// Create files and directories
env.CreateDirectory("subdir");
env.CreateFile("subdir/file.txt", "content");
env.CreateFiles("a.txt", "b.txt", "c.txt");
// Resolve absolute paths
var path = env.Abs("subdir");
var fullPath = env.Abs("subdir", "file.txt");
// Simulate inaccessible directories
var pseudo = InaccessibleDirectorySimulator.CreatePseudoInaccessibleDir(env, "restricted");
var locked = InaccessibleDirectorySimulator.CreateLockedDir(env, "locked", out var lockStream);
Project Structure
Jeninnet.Assertions/
├── ActionAssertions.cs # Synchronous exception assertions
├── AsyncActionAssertions.cs # Async exception assertions
├── BoolAssertions.cs # Boolean value assertions
├── CollectionAssertions.cs # Collection assertions
├── ObjectAssertions.cs # Generic object assertions
├── StringAssertions.cs # String value assertions
├── AssertionExtensions.cs # Should() entry points
├── AssertionFailedException.cs # Framework-agnostic assertion exception
├── ExceptionAssertions.cs # Exception result wrapper
├── WhichConstraint.cs # Container for single-item assertion results
├── Extensions/
│ ├── PathExtensions.cs # Path comparison extensions
│ └── TestEnvironmentExtensions.cs # TestEnvironment extensions
├── IO/
│ ├── InaccessibleDirectorySimulator.cs # Inaccessible directory simulation
│ └── TestEnvironment.cs # Isolated temp directory management
├── Utilities/
│ └── PathHelper.cs # Path join/normalize/compare helpers
├── GlobalUsings.cs
└── README.md
Extending
Add a new assertion type:
- Create an assertion class (e.g.,
NumericAssertions). - Add a
Should()extension method inAssertionExtensions.cs. - Optionally add XML documentation.
Building and Testing
dotnet build tests/Jeninnet.Assertions.Tests/
dotnet test tests/Jeninnet.Assertions.Tests/
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- System.Text.Json (>= 10.0.12)
-
net10.0
- No dependencies.
-
net6.0
- System.Text.Json (>= 10.0.12)
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Jeninnet.Assertions:
| Package | Downloads |
|---|---|
|
Jeninnet.Assertions.Analyzer
Roslyn analyzer suggesting fluent Should() assertions over MSTest Assert calls, with code fixes. |
|
|
Jeninnet.Assertions.MSTest
Optional MSTest integration for Jeninnet.Assertions: surfaces fluent assertion failures as MSTest outcomes. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 216 | 10/13/2026 |