Skip to content
Tracon

RunInputStoreContract

Namespace Tracon.Testing.Contracts.Storage · Assembly Tracon.Testing.Contracts.Xunit.dll

Behavior tests for the IRunInputStore contract.

public abstract class RunInputStoreContract : StoreCancellationContract<IRunInputStore>, IAsyncLifetime, IAsyncDisposable
Inheritance
object ← StoreCancellationContract<IRunInputStore> ← RunInputStoreContract
Implements
IAsyncLifetime, IAsyncDisposable
Inherited Members
StoreCancellationContract<IRunInputStore>.CreateStoreAsync(), StoreCancellationContract<IRunInputStore>.InitializeAsync(), StoreCancellationContract<IRunInputStore>.DisposeAsync(), StoreCancellationContract<IRunInputStore>.OnDisposeAsync(), StoreCancellationContract<IRunInputStore>.CancellableReadAsync(CancellationToken), StoreCancellationContract<IRunInputStore>.CancellableWriteAsync(CancellationToken), StoreCancellationContract<IRunInputStore>.WroteAnythingAsync(), StoreCancellationContract<IRunInputStore>.Canceled_token_throws_on_read(), StoreCancellationContract<IRunInputStore>.The_write_this_contract_checks_can_be_read_back(), StoreCancellationContract<IRunInputStore>.Canceled_token_throws_on_write_and_leaves_no_trace(), StoreCancellationContract<IRunInputStore>.Store, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Every implementation must pass the same scenarios.

The most valuable test is RunInputStoreContract.Polymorphic_content_round_trips_with_KEY_ORDER_preserved: a store that reorders object keys on write (for example, one backed by a JSON-typed column) can silently move the $type discriminator away from the first property, and the read then fails with a JsonException. Neither the build nor the other tests catch this.

protected RunInputStoreContract()

A_run_with_values_and_no_messages_still_records_the_values()

Section titled “ A_run_with_values_and_no_messages_still_records_the_values()”
[Fact]
public Task A_run_with_values_and_no_messages_still_records_the_values()

Task

[Fact]
public Task Another_tenants_input_cannot_be_read()

Task

Calls one read method of the store with the given token.

protected override ValueTask CancellableReadAsync(CancellationToken cancellationToken)

cancellationToken CancellationToken

The token the store must observe.

ValueTask

The completion task; any result is discarded.

Calls one write method of the store with the given token.

protected override ValueTask CancellableWriteAsync(CancellationToken cancellationToken)

cancellationToken CancellationToken

The token the store must observe.

ValueTask

The completion task.

The write must be one StoreCancellationContract.WroteAnythingAsync can see. A write this contract cannot read back proves nothing about side effects, which is why StoreCancellationContract.The_write_this_contract_checks_can_be_read_back runs the same pair with a live token and requires the read to find it.

Missing_parameters_and_empty_parameters_stay_distinct()

Section titled “ Missing_parameters_and_empty_parameters_stay_distinct()”
[Fact]
public Task Missing_parameters_and_empty_parameters_stay_distinct()

Task

[Fact]
public Task Parameter_values_round_trip_exactly()

Task

Polymorphic_content_round_trips_with_KEY_ORDER_preserved()

Section titled “ Polymorphic_content_round_trips_with_KEY_ORDER_preserved()”
[Fact]
public Task Polymorphic_content_round_trips_with_KEY_ORDER_preserved()

Task

Opens a run row at the given id before an input is written.

protected virtual ValueTask PrepareRunAsync(Guid runId, string tenantId)

runId Guid

The run id.

tenantId string

The tenant id.

ValueTask

The completion task.

In the SQL implementations, run_inputs.run_id is a foreign key into the runs table; the in-memory implementation has no such link, and the hook does nothing.

[Fact]
public Task Run_without_a_record_returns_null()

Task

[Fact]
public Task Second_write_is_IGNORED()

Task

Second_write_never_changes_the_recorded_parameters()

Section titled “ Second_write_never_changes_the_recorded_parameters()”
[Fact]
public Task Second_write_never_changes_the_recorded_parameters()

Task

[Fact]
public Task Written_input_round_trips_exactly()

Task

Reports whether StoreCancellationContract.CancellableWriteAsync left anything behind.

protected override ValueTask<bool> WroteAnythingAsync()

ValueTask<bool>

true if the store holds any record the write would have created.