TimeAssertions 0.8.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package TimeAssertions --version 0.8.0
                    
NuGet\Install-Package TimeAssertions -Version 0.8.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="TimeAssertions" Version="0.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TimeAssertions" Version="0.8.0" />
                    
Directory.Packages.props
<PackageReference Include="TimeAssertions" />
                    
Project file
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 TimeAssertions --version 0.8.0
                    
#r "nuget: TimeAssertions, 0.8.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 TimeAssertions@0.8.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=TimeAssertions&version=0.8.0
                    
Install as a Cake Addin
#tool nuget:?package=TimeAssertions&version=0.8.0
                    
Install as a Cake Tool

TimeAssertions

NuGet License: MIT .NET

Scope: Test projects only. Not intended for production code.

Framework-agnostic rendering helpers and test infrastructure for the TimeAssertions package family. The actual FakeTimeProvider and TimeProvider-aware DateTimeOffset assertion APIs ship in the framework-specific adapter packages (currently TimeAssertions.TUnit).

Most users want TimeAssertions.TUnit, not this package directly. This package only ships the shared rendering helpers; the adapter package adds the assertion entry points your test framework expects.


What's in this package

  • TimeRenderingHelpers: formatting utilities for elapsed durations and time budgets in failure-message context. Pure, allocation-conscious.
  • ObservableTimeProvider: a TimeProvider decorator that tracks the timers created against it (ActiveTimerCount, ActiveTimers, NextTimerDueTime) so adapter packages can assert on timer-disposal, leak, and pending-due-time behaviour without advancing the clock. Reflection-free, AOT-compatible, thread-safe.
  • ActiveTimerInfo: a readonly record struct describing a tracked timer's schedule (DueTime, Period), returned by ObservableTimeProvider.ActiveTimers.
  • TimelineRenderer / TimelineEvent: render a sequence of timestamped events as deterministic, snapshot-friendly text.

Test-framework adapters

Package Test framework Status
TimeAssertions.TUnit TUnit Available now
TimeAssertions.NUnit NUnit Possible if there is demand
TimeAssertions.xUnit xUnit Possible if there is demand
TimeAssertions.MSTest MSTest Possible if there is demand

If you'd find a non-TUnit adapter useful, open a feature request: adapters are not built proactively.

Installation

dotnet add package TimeAssertions.TUnit

TimeAssertions comes transitively. You don't need to install it directly unless you're building your own adapter package.

Stability

The public surfaces above are semver-bound. Breaking changes require a major version bump. The exact text format of TimeRenderingHelpers output is not stable and may gain extra detail or change formatting in any release.

License

MIT. Copyright (c) 2026 John Verheij.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TimeAssertions:

Package Downloads
TimeAssertions.TUnit

TUnit-native fluent time-assertion DSL on FakeTimeProvider plus assertion-level timing budget chain extensions via [AssertionExtension]. Provides Assert.That(fakeTime).HasAdvancedExactly(...) / HasAdvancedApproximately(...) / HasUtcNow(...) / HasUtcNowApproximately(...), Assert.That(timestamp).IsRecent(...) / IsBeforeNow(...) / IsAfterNow(...), and the cross-cutting Assert.That(value).IsX().And.WithinTimeBudget(TimeSpan) / WithinTimeBudgetCapturing(TimeSpan, Action<TimeSpan>) on any TUnit assertion chain. Composes with sibling assertion packages without a binary dependency. AOT-compatible, trimmable, no reflection.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.0 761 6/12/2026
0.8.1 1,618 6/6/2026
0.8.0 165 6/5/2026
0.7.0 250 6/4/2026
0.6.0 156 6/3/2026
0.5.0 245 5/19/2026
0.4.0 359 5/13/2026
0.3.0 176 5/12/2026
0.2.0 183 5/7/2026
0.1.0 163 5/6/2026

View the rendered release notes: https://github.com/JohnVerheij/TimeAssertions.TUnit/releases/tag/v0.8.0

Minor release. Adds asynchronous lower-bound, upper-bound, and at-least-one active-timer assertions, completing the bounded-count set begun in `0.7.0`. Aligns the active-timer "eventually" assertions with the BCL `CancellationToken` naming and discoverability convention. Contains breaking changes (parameter rename and a namespace move); see Breaking below.

### Added

- **`Assert.That(time).HasAtLeastActiveTimerCountEventually(count, timeout, ...)`** polls the live active-timer count until it is at least `count`. The asynchronous lower-bound sibling of the synchronous `HasAtLeastActiveTimerCount(count)` and the exact-count `HasActiveTimerCountEventually`: the right shape for an asynchronous registration wait where more than one timer may register, where the exact-count form would flake once an additional timer registers and the synchronous form would race a not-yet-registered timer.
- **`Assert.That(time).HasAtMostActiveTimerCountEventually(count, timeout, ...)`** polls until the active-timer count is at most `count`. The upper-bound sibling for "the active set settles to no more than N" without pinning the exact survivor count. `HasAtMostActiveTimerCountEventually(0, ...)` is equivalent to `HasNoActiveTimersEventually`.
- **`Assert.That(time).HasActiveTimersEventually(timeout, ...)`** polls until at least one timer is active. The asynchronous counterpart of `HasActiveTimers()` and a named shorthand for `HasAtLeastActiveTimerCountEventually(1, ...)`.
- Positional-`CancellationToken` sugar overloads for all three new assertions, matching the existing `(timeout, token)` and `(count, timeout, token)` shapes.

### Changed

- The positional-`CancellationToken` sugar (`EventuallyTimerAssertionExtensions`) now lives in the globally imported `TUnit.Assertions.Extensions` namespace, the same namespace the source generator emits the canonical extensions into, so the `(timeout, token)` / `(count, timeout, token)` forms are discoverable wherever the generated extensions are, without an extra `using TimeAssertions.TUnit;`.
- Bumped `PackageValidationBaselineVersion` from `0.6.0` to `0.7.0` on both packages and regenerated `CompatibilitySuppressions.xml` for the new public types, the namespace move, and the parameter rename.

### Breaking

- The `CancellationToken` parameter on `HasNoActiveTimersEventually` and `HasActiveTimerCountEventually` is renamed from `ct` to `cancellationToken`, matching the BCL convention and the new bounded-count assertions. A call that passed the token by name (`ct: token`) must use `cancellationToken: token`; positional calls are unaffected.
- `EventuallyTimerAssertionExtensions` moved from the `TimeAssertions.TUnit` namespace to `TUnit.Assertions.Extensions`. Code that referenced the type by its full name must update the namespace; code that used the extension methods through `Assert.That(...)` is unaffected (and no longer needs `using TimeAssertions.TUnit;` for them).