Skip to content
Tracon

AgentDefinitionStoreContract

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

Behavior tests for the IAgentDefinitionStore contract.

public abstract class AgentDefinitionStoreContract : TenantIsolationContract<IAgentDefinitionStore>, IAsyncLifetime, IAsyncDisposable
Inheritance
object ← StoreCancellationContract<IAgentDefinitionStore> ← TenantIsolationContract<IAgentDefinitionStore> ← AgentDefinitionStoreContract
Implements
IAsyncLifetime, IAsyncDisposable
Inherited Members
TenantIsolationContract<IAgentDefinitionStore>.TenantA, TenantIsolationContract<IAgentDefinitionStore>.TenantB, TenantIsolationContract<IAgentDefinitionStore>.UseAmbientTenant(MutableTenantContext), TenantIsolationContract<IAgentDefinitionStore>.SeedAsync(string, string, CancellationToken), TenantIsolationContract<IAgentDefinitionStore>.ExistsAsync(string, object), TenantIsolationContract<IAgentDefinitionStore>.CountAsync(string, CancellationToken), TenantIsolationContract<IAgentDefinitionStore>.TryDeleteAsync(string, object), TenantIsolationContract<IAgentDefinitionStore>.TryOverwriteAsync(string, string), TenantIsolationContract<IAgentDefinitionStore>.CancellableReadAsync(CancellationToken), TenantIsolationContract<IAgentDefinitionStore>.CancellableWriteAsync(CancellationToken), TenantIsolationContract<IAgentDefinitionStore>.WroteAnythingAsync(), TenantIsolationContract<IAgentDefinitionStore>.Tenant_cannot_read_another_tenants_record(), TenantIsolationContract<IAgentDefinitionStore>.Tenant_reads_its_own_record(), TenantIsolationContract<IAgentDefinitionStore>.Tenant_does_not_see_another_tenants_record_in_the_list(), TenantIsolationContract<IAgentDefinitionStore>.Tenant_cannot_delete_another_tenants_record(), TenantIsolationContract<IAgentDefinitionStore>.Same_name_lives_independently_across_two_tenants(), TenantIsolationContract<IAgentDefinitionStore>.AmbientTenant, StoreCancellationContract<IAgentDefinitionStore>.CreateStoreAsync(), StoreCancellationContract<IAgentDefinitionStore>.InitializeAsync(), StoreCancellationContract<IAgentDefinitionStore>.DisposeAsync(), StoreCancellationContract<IAgentDefinitionStore>.OnDisposeAsync(), StoreCancellationContract<IAgentDefinitionStore>.CancellableReadAsync(CancellationToken), StoreCancellationContract<IAgentDefinitionStore>.CancellableWriteAsync(CancellationToken), StoreCancellationContract<IAgentDefinitionStore>.WroteAnythingAsync(), StoreCancellationContract<IAgentDefinitionStore>.Canceled_token_throws_on_read(), StoreCancellationContract<IAgentDefinitionStore>.The_write_this_contract_checks_can_be_read_back(), StoreCancellationContract<IAgentDefinitionStore>.Canceled_token_throws_on_write_and_leaves_no_trace(), StoreCancellationContract<IAgentDefinitionStore>.Store, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

These tests run against every implementation. A behavior difference between the in-memory store and the PostgreSQL store is a bug; this class catches that difference.

protected AgentDefinitionStoreContract()

Concurrent_first_saves_of_a_new_name_get_distinct_versions()

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

Task

Concurrent_saves_of_one_name_get_distinct_versions_across_a_delete()

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

Task

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.

DeleteAsync_of_a_name_that_never_existed_does_not_start_a_numbering()

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

Task

[Fact]
public Task DeleteAsync_removes_all_versions()

Task

Each_tenants_version_counter_is_its_own()

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

Task

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.

GetAsync_for_a_missing_definition_returns_null()

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

Task

GetVersionAsync_for_a_missing_agent_returns_null()

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

Task

GetVersionAsync_for_a_missing_version_returns_null()

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

Task

GetVersionAsync_returns_the_requested_version()

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

Task

[Fact]
public Task ListAsync_orders_by_name()

Task

ListVersionsAsync_orders_newest_to_oldest()

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

Task

One_tenants_delete_does_not_move_another_tenants_numbering()

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

Task

RollbackAsync_after_a_recreate_continues_the_numbering()

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

Task

RollbackAsync_for_a_deleted_agent_throws_and_keeps_the_numbering()

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

Task

RollbackAsync_for_a_missing_agent_throws()

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

Task

RollbackAsync_saves_the_old_version_as_a_new_version()

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

Task

RollbackAsync_to_a_missing_version_throws()

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

Task

SaveAsync_after_DeleteAsync_continues_the_numbering()

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

Task

SaveAsync_increments_version_and_keeps_history()

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

Task

[Fact]
public Task SaveAsync_marks_origin_as_database()

Task

SaveAsync_round_trips_all_definition_fields()

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

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.

The tenant is not a parameter on the interface; it is read from ITenantContext. Each hook therefore sets the active tenant first.

Tenant_cannot_roll_back_another_tenants_definition()

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

Task

The_numbering_survives_every_delete_not_only_the_first()

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

Task

Attempts to delete the record on behalf of the given tenant.

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

tenantId string

The tenant attempting the delete.

key object

The key returned by TenantIsolationContract.SeedAsync.

ValueTask<bool?>

true if the delete succeeded, false if the record was not found; null if the store does not offer deletion.