Class TestObservability

Namespace
XBullet.EasyTesting.Observability
Assembly
XBullet.EasyTesting.Observability.dll

Owns deterministic time and captured observability signals for one scenario.

public sealed class TestObservability : ITestScenarioEnvironmentResource, IAsyncDisposable
Inheritance
TestObservability
Implements
Inherited Members

Remarks

Constructors

TestObservability(TestObservabilityOptions?)

Creates scenario observability from the supplied options.

public TestObservability(TestObservabilityOptions? options = null)

Parameters

options TestObservabilityOptions

The configuration to read immediately, or null to use defaults. Maximums must be positive. The options object is not retained, and later changes do not affect this resource.

Remarks

This resource owns its three collectors and any fake time provider. Callers may use the exposed objects while the scenario is active but must not dispose them separately.

Properties

Activities

Gets the completed-activity collector.

public TestActivityCollector Activities { get; }

Property Value

TestActivityCollector

The scenario-owned bounded listener for completed activities.

Logs

Gets the structured application-log collector.

public TestLogCollector Logs { get; }

Property Value

TestLogCollector

The scenario-owned bounded collector registered as the host's logging provider.

Metrics

Gets the metric-measurement collector.

public TestMetricCollector Metrics { get; }

Property Value

TestMetricCollector

The scenario-owned bounded listener for supported numeric metric measurements.

Time

Gets deterministic time when enabled, otherwise null.

public FakeTimeProvider? Time { get; }

Property Value

FakeTimeProvider

The scenario-owned fake time provider registered as the application's TimeProvider, or null when system time remains configured. It also timestamps captured logs and metrics, but activity timestamps continue to come from Activity.

Methods

CaptureDiagnosticsAsync(CancellationToken)

Captures the current state before a failed scenario is cleaned up.

public ValueTask<object?> CaptureDiagnosticsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels 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.

ConfigureConfiguration(IConfigurationBuilder)

Adds configuration values after the external dependency has started.

public void ConfigureConfiguration(IConfigurationBuilder configuration)

Parameters

configuration IConfigurationBuilder

The application configuration builder to mutate. The caller owns the builder; the resource must not retain or dispose it.

ConfigureServices(IServiceCollection)

Adds or replaces services after the external dependency has started.

public void ConfigureServices(IServiceCollection services)

Parameters

services IServiceCollection

The scenario's service collection to mutate before the test host is built. The caller owns the collection; the resource must not retain or dispose it.

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

StartAsync(CancellationToken)

Starts the external dependency and waits until it is ready for the scenario.

public ValueTask StartAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels startup and readiness checks. When cancellation prevents scenario creation, the scenario context still disposes the resource. The default token does not request cancellation.

Returns

ValueTask

A task that completes when the dependency is ready for the test host.