Goodtocode.Assertion
1.1.28
dotnet add package Goodtocode.Assertion --version 1.1.28
NuGet\Install-Package Goodtocode.Assertion -Version 1.1.28
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="Goodtocode.Assertion" Version="1.1.28" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Goodtocode.Assertion" Version="1.1.28" />
<PackageReference Include="Goodtocode.Assertion" />
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 Goodtocode.Assertion --version 1.1.28
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Goodtocode.Assertion, 1.1.28"
#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 Goodtocode.Assertion@1.1.28
#: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=Goodtocode.Assertion&version=1.1.28
#tool nuget:?package=Goodtocode.Assertion&version=1.1.28
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Goodtocode.Assertion
Fluent Assertion aspect-oriented library for .NET Standard 2.0+
Goodtocode.Assertion is a .NET library providing fluent assertion and validation utilities for C# projects. It enables developers to write expressive, readable, and maintainable assertions for business logic, unit tests, and runtime validation. The library is designed for extensibility and can be integrated into any .NET Standard 2.0+ project.
Features
- Fluent assertion syntax for clear, readable code
- Customizable assertion rules and exception handling
- Assertion scopes for grouping related checks
- Lightweight, dependency-free, and compatible with .NET Standard 2.0+
- Designed for use in both production code and unit tests
Quick-Start Steps
- Clone this repository
git clone https://github.com/goodtocode/aspect-assertion.git - Install .NET SDK (latest recommended)
winget install Microsoft.DotNet.SDK --silent - Build the solution
cd src dotnet build Goodtocode.Assertion.sln - Run tests
cd Goodtocode.Assertion.Tests dotnet test
Install Prerequisites
- .NET SDK (latest)
- Visual Studio (latest) or VS Code
Top Use Case Examples
1. Basic Assertion Scope
using Goodtocode.Assertion;
int value = 5;
AssertionScope.Begin()
.Assert(() => value > 0, "Value must be positive.")
.Assert(() => value < 10, "Value must be less than 10.")
.End();
2. Validating Object Properties
using Goodtocode.Assertion;
var user = new User { Name = "Alice", Age = 30 };
AssertionScope.Begin()
.Assert(() => !string.IsNullOrWhiteSpace(user.Name), "Name is required.")
.Assert(() => user.Age >= 18, "User must be an adult.")
.End();
3. Custom Validator for Business Logic
using Goodtocode.Assertion;
public class GetMyUsersPaginatedQueryValidator : Validator<GetMyUsersPaginatedQuery>
{
public GetMyUsersPaginatedQueryValidator()
{
RuleFor(v => v.StartDate).NotEmpty()
.When(v => v.EndDate != null)
.LessThanOrEqualTo(v => v.EndDate);
RuleFor(v => v.EndDate)
.NotEmpty()
.When(v => v.StartDate != null)
.GreaterThanOrEqualTo(v => v.StartDate);
RuleFor(x => x.PageNumber).NotEqual(0);
RuleFor(x => x.PageSize).NotEqual(0);
}
}
4. Unit Test Assertion
using Goodtocode.Assertion;
using Xunit;
[Fact]
public void Should_Throw_When_Assertion_Fails()
{
Assert.Throws<AssertionFailedException>(() =>
AssertionScope.Begin()
.Assert(() => false, "This should fail.")
.End());
}
Technologies
Version History
| Version | Date | Release Notes |
|---|---|---|
| 1.0.0 | 2026-Jan-19 | Initial release |
License
This project is licensed with the MIT license.
Contact
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. |
| .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
- 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.1.28 | 27 | 1/20/2026 |
| 1.1.25 | 25 | 1/20/2026 |
| 1.1.19.1711 | 30 | 1/19/2026 |
| 1.1.19.1701 | 35 | 1/19/2026 |
| 1.1.19.1644 | 32 | 1/19/2026 |
| 1.1.1 | 33 | 1/19/2026 |
| 1.0.0 | 33 | 1/19/2026 |