Table of Contents

Class TimelineRenderer

Namespace
TimeAssertions.Render
Assembly
TimeAssertions.dll

Pure renderer that converts a sequence of TimelineEvent into deterministic multi-line text suitable for snapshot comparison. Each event renders as +{deltaMs}ms label, where deltaMs is the millisecond offset from the caller-supplied epoch (negative deltas render with a leading minus sign and no plus).

public static class TimelineRenderer
Inheritance
TimelineRenderer
Inherited Members

Remarks

Pairs naturally with snapshot assertions. Render the timeline once, then pin the result against a baseline:

var rendered = TimelineRenderer.Render(epoch, events);
await Assert.That(rendered).MatchesSnapshot();

The MatchesSnapshot() extension above lives in the sibling SnapshotAssertions.TUnit package; this package does not depend on it. The two-line composition is deliberate: it lets consumers reach for the renderer without committing to a specific snapshot framework, and lets the SnapshotAssertions package stay an opt-in pairing rather than a transitive dependency.

Caller sorts. The renderer preserves input order verbatim, including ties on Timestamp. If the snapshot needs a specific ordering (chronological, by-category, etc.) the caller sorts the input list first.

Allocation-conscious. A StringBuilder with capacity precomputed from the input count avoids the resize cascade that would surface on large timelines. All numeric formatting uses InvariantCulture to keep snapshots stable across locales.

Deterministic line endings. Lines are terminated with the literal LF byte ('\n'), not NewLine. The CRLF / LF split between Windows and Unix would break the "byte-stable output" contract: the same timeline would serialise differently per OS, producing snapshot mismatches on cross-platform CI. Hardcoding LF keeps snapshots committed on one platform compatible with test runs on every other.

Methods

Render(DateTimeOffset, IReadOnlyList<TimelineEvent>)

Renders events as a deterministic, snapshot-friendly multi-line string, one event per line, deltas relative to epoch.

public static string Render(DateTimeOffset epoch, IReadOnlyList<TimelineEvent> events)

Parameters

epoch DateTimeOffset

The zero-moment against which every event's Timestamp is rendered as a relative delta.

events IReadOnlyList<TimelineEvent>

The events to render, in the order they should appear. Empty input produces Empty.

Returns

string

A multi-line string with one +{deltaMs}ms label line per event, or Empty when events is empty.

Exceptions

ArgumentNullException

events is null.