About this project

MathAssertions.TUnit is a .NET test-only assertion library for the TUnit framework and part of the DotNetAssertions family. It is not intended for production code. The repository ships two NuGet packages: MathAssertions, the framework-agnostic core with static helper classes and geometry primitives, and MathAssertions.TUnit, the TUnit adapter exposing about 85 fluent entry points across twelve adapter classes. Fluent entry points are generated with TUnit's [GenerateAssertion] source generator and integrate into Assert.That(value).Method(...). Requirements are TUnit 1.66.27 or later and .NET 10; the assertion path uses no runtime reflection and is AOT-compatible and trimmable. Coverage includes tolerance comparisons for scalars, System.Numerics compounds (Vector2/3/4, Quaternion, Matrix4x4, Plane, Complex), spans, and generic ReadOnlyTensorSpan; quaternion rotational equivalence handling the SO(3) double cover; axis-angle form assertions; combined pose and rigid transform approximate equality with separate position and rotation tolerances; sequence predicates for monotonicity, sortedness, boundedness, progressions, and Cauchy convergence; statistics via Welford mean and variance, median, percentile, standard deviation; linear algebra invariants for Matrix4x4 and Vector3 pairs; long-integer number theory predicates such as divisibility, overflow-safe primality, coprimality, GCD/LCM, perfect square, and modular congruence; and a 3D geometry surface with eight primitive record struct types, containment, closest-point, intersection, and pointcloud aggregate checks. Failure messages for compound types include per-component or per-cell delta and exceeded-axis diagnostics. The MathAssertions.Render namespace provides PoseRenderer for deterministic, snapshot-friendly text rendering of position and orientation poses for use with SnapshotAssertions.TUnit. Design details: approximate equality is component-wise rather than Euclidean distance, values are widened to double before comparison so a double tolerance is honored at full precision, and NaN and infinity semantics are documented as matching TUnit's IsCloseTo primitive. The companion MathAssertions package can be reused by other test frameworks, but adapters for NUnit, xUnit, or MSTest are not currently shipped. ReadOnlyTensorSpan is exposed only at the static MathTolerance level because TUnit's [GenerateAssertion] builder cannot capture ref-struct values across an await. The README also shows how to extend the DSL to consumer-defined domain types with a one-line [GenerateAssertion] extension, how to project protobuf pose messages into System.Numerics types, and how to combine assertions with Assert.Multiple. License: MIT.