Skip to content
Tracon

AttachmentStoreContract

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

Behavior tests for the IAttachmentStore contract.

public abstract class AttachmentStoreContract : TenantIsolationContract<IAttachmentStore>, IAsyncLifetime, IAsyncDisposable
Inheritance
object ← StoreCancellationContract<IAttachmentStore> ← TenantIsolationContract<IAttachmentStore> ← AttachmentStoreContract
Implements
IAsyncLifetime, IAsyncDisposable
Inherited Members
TenantIsolationContract<IAttachmentStore>.TenantA, TenantIsolationContract<IAttachmentStore>.TenantB, TenantIsolationContract<IAttachmentStore>.UseAmbientTenant(MutableTenantContext), TenantIsolationContract<IAttachmentStore>.SeedAsync(string, string, CancellationToken), TenantIsolationContract<IAttachmentStore>.ExistsAsync(string, object), TenantIsolationContract<IAttachmentStore>.CountAsync(string, CancellationToken), TenantIsolationContract<IAttachmentStore>.TryDeleteAsync(string, object), TenantIsolationContract<IAttachmentStore>.TryOverwriteAsync(string, string), TenantIsolationContract<IAttachmentStore>.CancellableReadAsync(CancellationToken), TenantIsolationContract<IAttachmentStore>.CancellableWriteAsync(CancellationToken), TenantIsolationContract<IAttachmentStore>.WroteAnythingAsync(), TenantIsolationContract<IAttachmentStore>.Tenant_cannot_read_another_tenants_record(), TenantIsolationContract<IAttachmentStore>.Tenant_reads_its_own_record(), TenantIsolationContract<IAttachmentStore>.Tenant_does_not_see_another_tenants_record_in_the_list(), TenantIsolationContract<IAttachmentStore>.Tenant_cannot_delete_another_tenants_record(), TenantIsolationContract<IAttachmentStore>.Same_name_lives_independently_across_two_tenants(), TenantIsolationContract<IAttachmentStore>.AmbientTenant, StoreCancellationContract<IAttachmentStore>.CreateStoreAsync(), StoreCancellationContract<IAttachmentStore>.InitializeAsync(), StoreCancellationContract<IAttachmentStore>.DisposeAsync(), StoreCancellationContract<IAttachmentStore>.OnDisposeAsync(), StoreCancellationContract<IAttachmentStore>.CancellableReadAsync(CancellationToken), StoreCancellationContract<IAttachmentStore>.CancellableWriteAsync(CancellationToken), StoreCancellationContract<IAttachmentStore>.WroteAnythingAsync(), StoreCancellationContract<IAttachmentStore>.Canceled_token_throws_on_read(), StoreCancellationContract<IAttachmentStore>.The_write_this_contract_checks_can_be_read_back(), StoreCancellationContract<IAttachmentStore>.Canceled_token_throws_on_write_and_leaves_no_trace(), StoreCancellationContract<IAttachmentStore>.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; in particular, tenant isolation and attachments being removed when a session is deleted must behave identically.

protected AttachmentStoreContract()

Another_tenants_attachment_is_not_visible()

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

Task

Bulk_delete_by_session_removes_only_matches()

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

Task

[Fact]
public Task Content_is_read_back_as_is()

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.

Delete_succeeds_once_and_returns_false_the_second_time()

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

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 Listing_filters_by_session()

Task

[Fact]
public Task Record_metadata_is_stored_correctly()

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.

Session_based_delete_does_not_delete_the_others_attachments()

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

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.