CustomAssertions 1.0.0
See the version list below for details.
dotnet add package CustomAssertions --version 1.0.0
NuGet\Install-Package CustomAssertions -Version 1.0.0
<PackageReference Include="CustomAssertions" Version="1.0.0" />
<PackageVersion Include="CustomAssertions" Version="1.0.0" />
<PackageReference Include="CustomAssertions" />
paket add CustomAssertions --version 1.0.0
#r "nuget: CustomAssertions, 1.0.0"
#:package CustomAssertions@1.0.0
#addin nuget:?package=CustomAssertions&version=1.0.0
#tool nuget:?package=CustomAssertions&version=1.0.0
CustomAssertions
A modern, fluent assertion library for .NET that provides type-safe, chainable assertions with comprehensive validation capabilities. Designed to work seamlessly with xUnit, NUnit, and MSTest.
โจ Features
- ๐ Fluent API: Chain multiple assertions together for readable, expressive tests
- ๐ฏ Type-Safe: Strong typing with compile-time validation
- ๐ฆ Comprehensive: Assertions for strings, integers, collections, dates, records, structs, tuples, and more
- ๐งช Test Framework Agnostic: Works with xUnit, NUnit, MSTest
- ๐ Modern C#: Leverages latest C# features (records, pattern matching, nullable types)
- ๐ Well-Documented: Full XML documentation for IntelliSense support
- โก Performant: Minimal overhead with efficient implementation
- ๐ Detailed Error Messages: Clear, descriptive failure messages
๐ฆ Installation
Via NuGet Package Manager
Install-Package CustomAssertions
Via .NET CLI
dotnet add package CustomAssertions
Via PackageReference
<PackageReference Include="CustomAssertions" Version="1.0.0" />
๐ Quick Start
using CustomAssertions.ConcreteModels;
using Xunit;
public class ExampleTests
{
[Fact]
public void StringAssertion_Example()
{
var result = new StringAssertions("Hello, World!")
.NotNullOrEmpty()
.HasMinimumLength(5)
.Contains("World")
.MatchesRegex(@"^Hello.*!")
.Validate();
Assert.True(result);
}
[Fact]
public void IntAssertion_Example()
{
var result = new IntAssertions(42)
.IsPositive()
.IsGreaterThan(10)
.IsLessThan(100)
.IsInRange(1, 50)
.Validate();
Assert.True(result);
}
}
๐ Available Assertions
- StringAssertions: null/empty checks, length validations, regex matching, contains/not contains
- IntAssertions: positive/negative/zero, comparisons, range validation
- CollectionAssertions: empty/not empty, contains item
- DateTimeAssertions: before/after, date range, weekend checks
- DictionaryAssertions: key/value existence
- RecordAssertions: value equality for records
- NullableAssertions: has value, conditional validation
- StructAssertions: default value, equality checks
- TupleAssertions: length, item validation
- FloatingPointAssertions: approximate equality, range, special values (NaN, Infinity)
- CharAssertions: letter, digit, case, punctuation checks
- ByteAssertions: byte-specific comparisons and range validation
- GenericAssertions: type checks, custom predicates
๐๏ธ Architecture
The library follows these design principles:
- SOLID Principles: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
- Fluent Interface Pattern: Enables method chaining for readable code
- Template Method Pattern: Base classes define structure, concrete classes implement specifics
- Curiously Recurring Template Pattern (CRTP): Type-safe fluent chaining
๐ง Requirements
- .NET 6.0 or higher (.NET 6, .NET 7, .NET 8, .NET 9 supported)
- C# 10 or higher (for modern language features)
๐ License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Made with โค๏ธ by Darel Johnson
Copyright ยฉ 2024 Darel Johnson. All rights reserved.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 is compatible. 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 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 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. |
-
net6.0
- No dependencies.
-
net7.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.
Initial release of CustomAssertions library with comprehensive fluent assertion support for .NET 6+.