Class TestDurableEntityClient

Namespace
XBullet.EasyTesting.AzureFunctions
Assembly
XBullet.EasyTesting.AzureFunctions.dll

Records entity client operations without a Durable service.

public sealed class TestDurableEntityClient : DurableEntityClient, ITestScenarioResource
Inheritance
TestDurableEntityClient
Implements
Inherited Members
Extension Methods

Remarks

Signals record submissions only. Seeded metadata never changes automatically. Configure handlers before concurrent use and await in-flight calls before reset. Query and cleanup require explicit handlers.

Constructors

TestDurableEntityClient(string)

Creates an entity client.

public TestDurableEntityClient(string name = "test-client")

Parameters

name string

The non-empty client name.

Properties

CleanHandler

Gets or sets cleanup behavior.

public Func<CleanEntityStorageRequest?, bool, CancellationToken, Task<CleanEntityStorageResult>>? CleanHandler { get; set; }

Property Value

Func<CleanEntityStorageRequest?, bool, CancellationToken, Task<CleanEntityStorageResult>>

A required callback receiving the request, completion flag, and caller token.

GetEntityHandler

Gets or sets metadata lookup behavior.

public Func<EntityInstanceId, bool, CancellationToken, Task<EntityMetadata?>>? GetEntityHandler { get; set; }

Property Value

Func<EntityInstanceId, bool, CancellationToken, Task<EntityMetadata>>

An optional callback overriding fixtures. The fake projects its response to honor state inclusion.

Operations

Gets all entity client attempts, including handler failures.

public IReadOnlyList<RecordedEntityOperation> Operations { get; }

Property Value

IReadOnlyList<RecordedEntityOperation>

An ordered snapshot excluding invalid and pre-canceled calls.

QueryHandler

Gets or sets pageable query behavior.

public Func<EntityQuery?, AsyncPageable<EntityMetadata>>? QueryHandler { get; set; }

Property Value

Func<EntityQuery, AsyncPageable<EntityMetadata>>

A required callback returning SDK metadata pages. Typed queries deserialize included states.

SignalHandler

Gets or sets signal submission behavior.

public Func<RecordedEntityOperation, CancellationToken, Task>? SignalHandler { get; set; }

Property Value

Func<RecordedEntityOperation, CancellationToken, Task>

An optional callback receiving the recorded attempt and caller token; null accepts without delivery.

Methods

CaptureDiagnosticsAsync(CancellationToken)

Captures operation names, entity IDs, and call order.

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

Parameters

cancellationToken CancellationToken

Cancels before capture.

Returns

ValueTask<object>

A detached snapshot excluding state, inputs, options, and failures.

CleanEntityStorageAsync(CleanEntityStorageRequest?, bool, CancellationToken)

Cleans entity storage. See CleanEntityStorageRequest for the different forms of cleaning available.

public override Task<CleanEntityStorageResult> CleanEntityStorageAsync(CleanEntityStorageRequest? request = null, bool continueUntilComplete = true, CancellationToken cancellation = default)

Parameters

request CleanEntityStorageRequest?

The request which describes what to clean.

continueUntilComplete bool

Whether to keep going until the cleaning is complete, or to return intermediate results with a continuation token.

cancellation CancellationToken

The cancellation token to cancel the operation.

Returns

Task<CleanEntityStorageResult>

A task that completes when the operation is finished.

GetAllEntitiesAsync(EntityQuery?)

Queries entity instances, optionally filtering results with filter.

public override AsyncPageable<EntityMetadata> GetAllEntitiesAsync(EntityQuery? filter = null)

Parameters

filter EntityQuery

The optional query filter.

Returns

AsyncPageable<EntityMetadata>

An async pageable of the query results.

GetAllEntitiesAsync<T>(EntityQuery?)

Queries entity instances, optionally filtering results with filter.

public override AsyncPageable<EntityMetadata<T>> GetAllEntitiesAsync<T>(EntityQuery? filter = null)

Parameters

filter EntityQuery

The optional query filter.

Returns

AsyncPageable<EntityMetadata<T>>

An async pageable of the query results.

Type Parameters

T

The type of the entity state.

GetEntityAsync(EntityInstanceId, bool, CancellationToken)

Tries to get the entity with ID of id. Includes entity state by default.

public override Task<EntityMetadata?> GetEntityAsync(EntityInstanceId id, bool includeState = true, CancellationToken cancellation = default)

Parameters

id EntityInstanceId

The ID of the entity to get.

includeState bool

true to include entity state in the response, false to not.

cancellation CancellationToken

The cancellation token to cancel the operation.

Returns

Task<EntityMetadata>

A response containing metadata describing the entity, or null if the entity does not exist.

GetEntityAsync<T>(EntityInstanceId, bool, CancellationToken)

Tries to get the entity with ID of id. Includes entity state by default.

public override Task<EntityMetadata<T>?> GetEntityAsync<T>(EntityInstanceId id, bool includeState = true, CancellationToken cancellation = default)

Parameters

id EntityInstanceId

The ID of the entity to get.

includeState bool

true to include entity state in the response, false to not.

cancellation CancellationToken

The cancellation token to cancel the operation.

Returns

Task<EntityMetadata<T>>

A response containing metadata describing the entity, or null if the entity does not exist.

Type Parameters

T

The type of the entity state.

ResetAsync(CancellationToken)

Clears entity fixtures, recorded calls, and sequence numbers, retaining handlers.

public ValueTask ResetAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels before state changes.

Returns

ValueTask

A completed task after reset.

SignalEntityAsync(EntityInstanceId, string, object?, SignalEntityOptions?, CancellationToken)

Signals an entity to perform an operation.

public override Task SignalEntityAsync(EntityInstanceId id, string operationName, object? input = null, SignalEntityOptions? options = null, CancellationToken cancellation = default)

Parameters

id EntityInstanceId

The ID of the entity to signal.

operationName string

The name of the operation.

input object

The input for the operation.

options SignalEntityOptions

The options to signal the entity with.

cancellation CancellationToken

The cancellation token to cancel enqueuing of the operation.

Returns

Task

A task that completes when the message has been reliably enqueued.

Remarks

This does not wait for the operation to be processed by the receiving entity.

WithEntity(EntityMetadata)

Seeds serialized SDK metadata without serializing its wrapper again.

public TestDurableEntityClient WithEntity(EntityMetadata metadata)

Parameters

metadata EntityMetadata

The non-null fixture. Scalar values are copied; serialized state and converter are retained.

Returns

TestDurableEntityClient

This client for chaining.

WithEntity<T>(EntityMetadata<T>, DataConverter?)

Seeds an SDK metadata fixture, serializing included state immediately.

public TestDurableEntityClient WithEntity<T>(EntityMetadata<T> metadata, DataConverter? dataConverter = null)

Parameters

metadata EntityMetadata<T>

The non-null fixture to copy.

dataConverter DataConverter

The state converter, or the SDK JSON default.

Returns

TestDurableEntityClient

This client for chaining.

Type Parameters

T

The fixture state type.