Skip to content
Tracon

RetentionPolicyStoreContract

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

Behavior tests for the IRetentionPolicyStore contract.

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

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.

[Fact]
public Task Deleted_policy_is_not_read_back()

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.

[Fact]
public Task Failed_run_carries_the_error_message()

Task

Falls_back_to_the_wildcard_policy_when_no_tenant_specific_record_exists()

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

Task

[Fact]
public Task Run_history_returns_newest_first()

Task

Run_is_created_and_progress_accumulates()

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

Task

[Fact]
public Task Saved_policy_is_read_back()

Task

Saving_the_same_target_a_second_time_overwrites_it()

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

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.

Tenant_specific_record_takes_precedence_over_the_wildcard()

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

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.

Attempts to change the record’s content on behalf of the given tenant.

protected override ValueTask<bool> TryOverwriteAsync(string tenantId, string name)

tenantId string

The tenant attempting the update.

name string

The record’s name.

ValueTask<bool>

true if the update was attempted; false if the store does not support this scenario.

The default implementation calls TenantIsolationContract.SeedAsync a second time: writing a record with the same name verifies that two tenants can carry the same name independently.