Class TestActivityCollector
- Namespace
- XBullet.EasyTesting.Observability
- Assembly
- XBullet.EasyTesting.Observability.dll
Thread-safe listener that captures completed activities in memory.
public sealed class TestActivityCollector : ITestScenarioResource, IDisposable
- Inheritance
-
TestActivityCollector
- Implements
- Inherited Members
Constructors
TestActivityCollector(IEnumerable<string>?, int)
Creates a bounded collector, optionally restricted to exact source names.
public TestActivityCollector(IEnumerable<string>? sourceNames = null, int maximumEntries = 1000)
Parameters
sourceNamesIEnumerable<string>Exact, case-sensitive activity-source names to capture, or null or an empty sequence to capture every source. The sequence is enumerated immediately and duplicates are ignored.
maximumEntriesintThe positive maximum number of completed activities retained. The default is 1,000; when the bound is exceeded, the oldest entries are discarded first.
Properties
Count
Gets the number of currently captured completed activities.
public int Count { get; }
Property Value
- int
A value from zero through the configured maximum entry count.
Entries
Gets a stable copy of captured completed activities.
public IReadOnlyList<TestActivityEntry> Entries { get; }
Property Value
- IReadOnlyList<TestActivityEntry>
A newly allocated snapshot in completion order. The caller may retain the list. Entries can contain unredacted tags, baggage, and events with sensitive values.
Methods
CaptureDiagnosticsAsync(CancellationToken)
Captures the current state before a failed scenario is cleaned up.
public ValueTask<object?> CaptureDiagnosticsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels diagnostic collection for this resource. The default token does not request cancellation. A thrown exception, including cancellation, is recorded as a diagnostic capture failure so cleanup can continue.
Returns
- ValueTask<object>
A serializable diagnostic value, or null when the resource has no state to report. Ownership remains with the resource unless its implementation states otherwise.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Reset()
Removes every captured activity and returns this collector.
public TestActivityCollector Reset()
Returns
- TestActivityCollector
This collector, for chaining. The listener, filters, and maximum remain unchanged.
ResetAsync(CancellationToken)
Clears mutable state before and after a scenario.
public ValueTask ResetAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels this reset attempt. The default token does not request cancellation. The factory continues resetting the remaining registered resources and reports all reset failures together.
Returns
- ValueTask
A task that completes when the resource has finished resetting its state.
Should()
Starts a fluent assertion chain over captured activities.
public TestActivityCollectorAssertions Should()
Returns
- TestActivityCollectorAssertions
A new assertion object that reads this collector's current snapshots.