.NET API
StoreCancellationContract<TStore\>
Tracon.Testing.Contracts.Xunit.dllThe promise every store makes about a token that is already cancelled, plus the lifecycle plumbing every store contract shares.
public abstract class StoreCancellationContract<TStore> : IAsyncLifetime, IAsyncDisposable- Type Parameters
TStoreThe store type under test.- Inheritance
- object ← StoreCancellationContract<TStore>
- Implements
- IAsyncLifetime, IAsyncDisposable
- Inherited Members
- object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”A store handed a token that is already cancelled throws OperationCanceledException and leaves no trace. The write side is the half that matters: throwing on its own proves nothing, because a check placed after the work throws too. The contract therefore reads the store back and requires it to be untouched.
Cancellation during a call is deliberately outside this contract. It races, so no deterministic case can assert where the work stopped. Only a token that was already cancelled when the call started is covered.
Storage.TenantIsolationContract derives from this class and wires the three hooks to its own seed and count hooks, so a tenant-aware store contract implements nothing extra. The four store contracts that carry no tenant dimension derive from this class directly.
Constructors
Section titled “Constructors”StoreCancellationContract()
Section titled “ StoreCancellationContract()”protected StoreCancellationContract()Properties
Section titled “Properties”The store under test.
protected TStore Store { get; }Property Value
Section titled “Property Value”TStore
Methods
Section titled “Methods”Canceled_token_throws_on_read()
Section titled “ Canceled_token_throws_on_read()”[Fact]public Task Canceled_token_throws_on_read()Returns
Section titled “Returns”Canceled_token_throws_on_write_and_leaves_no_trace()
Section titled “ Canceled_token_throws_on_write_and_leaves_no_trace()”[Fact]public Task Canceled_token_throws_on_write_and_leaves_no_trace()Returns
Section titled “Returns”CancellableReadAsync(CancellationToken)
Section titled “ CancellableReadAsync(CancellationToken)”Calls one read method of the store with the given token.
protected abstract ValueTask CancellableReadAsync(CancellationToken cancellationToken)Parameters
Section titled “Parameters”cancellationToken CancellationToken
The token the store must observe.
Returns
Section titled “Returns”The completion task; any result is discarded.
CancellableWriteAsync(CancellationToken)
Section titled “ CancellableWriteAsync(CancellationToken)”Calls one write method of the store with the given token.
protected abstract ValueTask CancellableWriteAsync(CancellationToken cancellationToken)Parameters
Section titled “Parameters”cancellationToken CancellationToken
The token the store must observe.
Returns
Section titled “Returns”The completion task.
Remarks
Section titled “Remarks”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.
CreateStoreAsync()
Section titled “ CreateStoreAsync()”Produces an empty store for the test.
protected abstract ValueTask<TStore> CreateStoreAsync()Returns
Section titled “Returns”ValueTask<TStore>
A store ready for use.
DisposeAsync()
Section titled “ DisposeAsync()”public ValueTask DisposeAsync()Returns
Section titled “Returns”InitializeAsync()
Section titled “ InitializeAsync()”Called immediately after the class has been created, before it is used.
public ValueTask InitializeAsync()Returns
Section titled “Returns”OnDisposeAsync()
Section titled “ OnDisposeAsync()”Hook for a derived class to release its own resources.
protected virtual ValueTask OnDisposeAsync()Returns
Section titled “Returns”A completed task.
The_write_this_contract_checks_can_be_read_back()
Section titled “ The_write_this_contract_checks_can_be_read_back()”[Fact]public Task The_write_this_contract_checks_can_be_read_back()Returns
Section titled “Returns”WroteAnythingAsync()
Section titled “ WroteAnythingAsync()”Reports whether StoreCancellationContract.CancellableWriteAsync left anything behind.
protected abstract ValueTask<bool> WroteAnythingAsync()Returns
Section titled “Returns”true if the store holds any record the write would have created.