Class RedisLockProviderTest
[TestFixture]
public class RedisLockProviderTest
- Inheritance
-
RedisLockProviderTest
- Inherited Members
- Extension Methods
Methods
AcquireAsync_RetriesWithDelays_UntilNxSucceeds()
Verifies that AcquireAsync retries the underlying Nx-style StringSetAsync call with delays
between attempts when the operation initially fails, continuing until it succeeds.
Asserts the call is retried the expected number of times and that the elapsed time confirms
delays were actually applied between attempts.
[Test]
public Task AcquireAsync_RetriesWithDelays_UntilNxSucceeds()
Returns
AcquireAsync_ReturnsFalse_AfterTimeoutWithMultipleRetries()
Verifies that AcquireAsync returns false and performs multiple retry attempts when the underlying lock acquisition operation consistently fails within the specified timeout.
[Test]
public Task AcquireAsync_ReturnsFalse_AfterTimeoutWithMultipleRetries()
Returns
AcquireAsync_ReturnsTrue_AndStoresToken_WhenRedisAcceptsNxSet()
Verifies that AcquireAsync returns true, stores the lock token under the lock: prefixed key, applies the configured TTL, and uses the When.NotExists flag when Redis accepts the NX SET operation. Also asserts that a subsequent ReleaseAsync invokes the Redis release script.
[Test]
public Task AcquireAsync_ReturnsTrue_AndStoresToken_WhenRedisAcceptsNxSet()
Returns
ReleaseAsync_CallsScriptEvaluateWithCorrectKeyAndToken()
Verifies that releasing a lock invokes the Lua script evaluation with the correct lock key (prefixed with "lock:") and the token previously captured during lock acquisition.
[Test]
public Task ReleaseAsync_CallsScriptEvaluateWithCorrectKeyAndToken()
Returns
ReleaseAsync_IsIdempotent_WhenCalledWithoutPriorAcquire()
Verifies that ReleaseAsync is idempotent when invoked without a prior acquire operation, ensuring that no script evaluation is performed on the underlying database in this scenario.
[Test]
public Task ReleaseAsync_IsIdempotent_WhenCalledWithoutPriorAcquire()
Returns
SetUp()
Initializes the test environment by creating a mock StackExchange.Redis.IDatabase and instantiating a RedisLockProvider configured to use the mocked database.
[SetUp]
public void SetUp()