Skip to content
Tracon

ToolInvocationContract

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

Behavior tests for the IRunStore tool-invocation contract.

public abstract class ToolInvocationContract : TenantIsolationContract<IRunStore>, IAsyncLifetime, IAsyncDisposable
Inheritance
object ← StoreCancellationContract<IRunStore> ← TenantIsolationContract<IRunStore> ← ToolInvocationContract
Implements
IAsyncLifetime, IAsyncDisposable
Inherited Members
TenantIsolationContract<IRunStore>.TenantA, TenantIsolationContract<IRunStore>.TenantB, TenantIsolationContract<IRunStore>.UseAmbientTenant(MutableTenantContext), TenantIsolationContract<IRunStore>.SeedAsync(string, string, CancellationToken), TenantIsolationContract<IRunStore>.ExistsAsync(string, object), TenantIsolationContract<IRunStore>.CountAsync(string, CancellationToken), TenantIsolationContract<IRunStore>.TryDeleteAsync(string, object), TenantIsolationContract<IRunStore>.TryOverwriteAsync(string, string), TenantIsolationContract<IRunStore>.CancellableReadAsync(CancellationToken), TenantIsolationContract<IRunStore>.CancellableWriteAsync(CancellationToken), TenantIsolationContract<IRunStore>.WroteAnythingAsync(), TenantIsolationContract<IRunStore>.Tenant_cannot_read_another_tenants_record(), TenantIsolationContract<IRunStore>.Tenant_reads_its_own_record(), TenantIsolationContract<IRunStore>.Tenant_does_not_see_another_tenants_record_in_the_list(), TenantIsolationContract<IRunStore>.Tenant_cannot_delete_another_tenants_record(), TenantIsolationContract<IRunStore>.Same_name_lives_independently_across_two_tenants(), TenantIsolationContract<IRunStore>.AmbientTenant, StoreCancellationContract<IRunStore>.CreateStoreAsync(), StoreCancellationContract<IRunStore>.InitializeAsync(), StoreCancellationContract<IRunStore>.DisposeAsync(), StoreCancellationContract<IRunStore>.OnDisposeAsync(), StoreCancellationContract<IRunStore>.CancellableReadAsync(CancellationToken), StoreCancellationContract<IRunStore>.CancellableWriteAsync(CancellationToken), StoreCancellationContract<IRunStore>.WroteAnythingAsync(), StoreCancellationContract<IRunStore>.Canceled_token_throws_on_read(), StoreCancellationContract<IRunStore>.The_write_this_contract_checks_can_be_read_back(), StoreCancellationContract<IRunStore>.Canceled_token_throws_on_write_and_leaves_no_trace(), StoreCancellationContract<IRunStore>.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 summary is computed in the store itself, not by fetching rows and aggregating them in memory.

protected ToolInvocationContract()

A_late_settlement_does_not_count_as_a_second_call()

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

Task

A_late_settlement_never_erases_a_measurement_the_row_already_carries()

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

Task

A_measurement_that_names_no_provider_or_model_comes_back_with_none()

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

Task

A_second_late_settlement_for_the_same_call_changes_nothing()

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

Task

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.

Reports how many records the given tenant sees through the listing endpoint.

protected override ValueTask<int> CountAsync(string tenantId, CancellationToken cancellationToken)

tenantId string

The reading tenant.

cancellationToken CancellationToken

The token every store call inside the hook must be handed; see TenantIsolationContract.SeedAsync.

ValueTask<int>

The number of records seen.

Reports whether the record is visible from the given tenant’s viewpoint.

protected override ValueTask<bool> ExistsAsync(string tenantId, object key)

tenantId string

The reading tenant.

key object

The key returned by TenantIsolationContract.SeedAsync.

ValueTask<bool>

true if the record is visible.

Failed_invocation_is_counted_as_unsuccessful()

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

Task

[Fact]
public Task Invocation_fields_round_trip()

Task

Invocation_with_no_reported_usage_comes_back_with_EMPTY_usage()

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

Task

[Fact]
public Task Invocations_come_back_in_time_order()

Task

Late_settlement_fills_in_the_timed_out_record_without_rewriting_what_the_model_was_told()

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

Task

Late_settlement_for_an_unknown_call_reports_that_it_wrote_nothing()

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

Task

Late_settlement_from_the_wrong_tenant_writes_nothing()

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

Task

Late_settlement_touches_only_the_call_it_names()

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

Task

[Fact]
public Task Non_token_measurement_round_trips()

Task

SeedAsync(string, string, CancellationToken)

Section titled “ SeedAsync(string, string, CancellationToken)”

Writes a sample record for the given tenant.

protected override ValueTask<object> SeedAsync(string tenantId, string name, CancellationToken cancellationToken)

tenantId string

The tenant that owns the record.

name string

The name distinguishing the record. The same name may be used by two tenants.

cancellationToken CancellationToken

The token every store call inside the hook must be handed. The cancellation contract calls this hook with a token that is already cancelled, so a hook that drops the token reports a store as sound when it is not.

ValueTask<object>

The key to use for reading the record back.

A tool invocation is attached to a run; isolation is established through the run’s tenant.

Summary_does_not_count_another_tenants_invocations()

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

Task

[Fact]
public Task Summary_is_aggregated_per_tool()

Task

Summary_is_ordered_by_call_count_and_limited()

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

Task

[Fact]
public Task Unknown_duration_stays_empty()

Task