.NET API
SingletonLeaseStoreContract
Tracon.Testing.Contracts.Xunit.dllBehavior tests for the ISingletonLeaseStore contract.
public abstract class SingletonLeaseStoreContract : StoreCancellationContract<ISingletonLeaseStore>, IAsyncLifetime, IAsyncDisposable- Inheritance
- object ← StoreCancellationContract<ISingletonLeaseStore> ← SingletonLeaseStoreContract
- Implements
- IAsyncLifetime, IAsyncDisposable
- Inherited Members
- StoreCancellationContract<ISingletonLeaseStore>.CreateStoreAsync(), StoreCancellationContract<ISingletonLeaseStore>.InitializeAsync(), StoreCancellationContract<ISingletonLeaseStore>.DisposeAsync(), StoreCancellationContract<ISingletonLeaseStore>.OnDisposeAsync(), StoreCancellationContract<ISingletonLeaseStore>.CancellableReadAsync(CancellationToken), StoreCancellationContract<ISingletonLeaseStore>.CancellableWriteAsync(CancellationToken), StoreCancellationContract<ISingletonLeaseStore>.WroteAnythingAsync(), StoreCancellationContract<ISingletonLeaseStore>.Canceled_token_throws_on_read(), StoreCancellationContract<ISingletonLeaseStore>.The_write_this_contract_checks_can_be_read_back(), StoreCancellationContract<ISingletonLeaseStore>.Canceled_token_throws_on_write_and_leaves_no_trace(), StoreCancellationContract<ISingletonLeaseStore>.Store, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”The in-memory store and the three SQL providers must pass the same
scenarios. The lease-expiry test runs against real time (a short lease
plus a short wait): the SQL implementations do not take their clock from
an injectable TimeProvider – the same reason as
JobStoreContract.
There is no tenant concept here: single-executor election is a
deployment-wide concern. This is why the contract derives from
Storage.StoreCancellationContract rather than from
Storage.TenantIsolationContract – the same pattern as
RetentionStoreContract.
Constructors
Section titled “Constructors”SingletonLeaseStoreContract()
Section titled “ SingletonLeaseStoreContract()”protected SingletonLeaseStoreContract()Methods
Section titled “Methods”CancellableReadAsync(CancellationToken)
Section titled “ CancellableReadAsync(CancellationToken)”Calls one read method of the store with the given token.
protected override 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.
Remarks
Section titled “Remarks”A lease store has no pure query. Renewing a lease nobody holds is the closest thing to one: it reports false and writes nothing.
CancellableWriteAsync(CancellationToken)
Section titled “ CancellableWriteAsync(CancellationToken)”Calls one write method of the store with the given token.
protected override 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.
Empty_lease_can_be_acquired()
Section titled “ Empty_lease_can_be_acquired()”[Fact]public Task Empty_lease_can_be_acquired()Returns
Section titled “Returns”Owner_can_renew_its_lease()
Section titled “ Owner_can_renew_its_lease()”[Fact]public Task Owner_can_renew_its_lease()Returns
Section titled “Returns”ReleaseAsync_by_a_non_owner_does_nothing()
Section titled “ ReleaseAsync_by_a_non_owner_does_nothing()”[Fact]public Task ReleaseAsync_by_a_non_owner_does_nothing()Returns
Section titled “Returns”Released_lease_can_be_reacquired_immediately_by_someone_else()
Section titled “ Released_lease_can_be_reacquired_immediately_by_someone_else()”[Fact]public Task Released_lease_can_be_reacquired_immediately_by_someone_else()Returns
Section titled “Returns”RenewAsync_returns_false_for_a_non_owner()
Section titled “ RenewAsync_returns_false_for_a_non_owner()”[Fact]public Task RenewAsync_returns_false_for_a_non_owner()Returns
Section titled “Returns”RenewAsync_returns_false_once_the_lease_has_passed_to_someone_else()
Section titled “ RenewAsync_returns_false_once_the_lease_has_passed_to_someone_else()”[Fact]public Task RenewAsync_returns_false_once_the_lease_has_passed_to_someone_else()Returns
Section titled “Returns”Same_owner_can_reacquire_its_own_lease()
Section titled “ Same_owner_can_reacquire_its_own_lease()”[Fact]public Task Same_owner_can_reacquire_its_own_lease()Returns
Section titled “Returns”Second_owner_cannot_acquire_while_lease_is_held()
Section titled “ Second_owner_cannot_acquire_while_lease_is_held()”[Fact]public Task Second_owner_cannot_acquire_while_lease_is_held()Returns
Section titled “Returns”Someone_else_can_acquire_once_the_lease_expires()
Section titled “ Someone_else_can_acquire_once_the_lease_expires()”[Fact]public Task Someone_else_can_acquire_once_the_lease_expires()Returns
Section titled “Returns”WroteAnythingAsync()
Section titled “ WroteAnythingAsync()”Reports whether StoreCancellationContract.CancellableWriteAsync left anything behind.
protected override ValueTask<bool> WroteAnythingAsync()Returns
Section titled “Returns”true if the store holds any record the write would have created.
Remarks
Section titled “Remarks”A different owner asks for the same lease. It can only take it if the cancelled call left no row behind.