Table of Contents

Class InMemoryLockProviderTest

Namespace
adas_core.Test.Services
Assembly
adas-core.Test.dll
[TestFixture]
public class InMemoryLockProviderTest
Inheritance
InMemoryLockProviderTest
Inherited Members
Extension Methods

Methods

AcquireAsync_IsThreadSafe_OnlyOneHolderAtATime_SingleSemaphorePerKey()

Verifies that AcquireAsync is thread-safe for a given key, ensuring that only one caller can hold the semaphore at a time even when multiple tasks compete concurrently for the same key, and that a single semaphore instance is created and reused per key.

[Test]
public Task AcquireAsync_IsThreadSafe_OnlyOneHolderAtATime_SingleSemaphorePerKey()

Returns

Task

AcquireAsync_ReturnsFalse_WhenSemaphoreOccupiedAndTimeoutExpires()

Verifies that AcquireAsync returns false when the semaphore for the specified key is already occupied and the requested timeout expires before the lock can be acquired, and that the underlying semaphore is restored to a count of 1 after release.

[Test]
public Task AcquireAsync_ReturnsFalse_WhenSemaphoreOccupiedAndTimeoutExpires()

Returns

Task

AcquireAsync_ReturnsTrue_AndCreatesEntryInLocksDictionary()

Verifies that AcquireAsync returns true and creates a corresponding entry in the locks dictionary when called with a valid key and time span.

[Test]
public Task AcquireAsync_ReturnsTrue_AndCreatesEntryInLocksDictionary()

Returns

Task

ReleaseAsync_DoesNotThrow_WhenCalledWithoutPriorAcquire()

Verifies that ReleaseAsync does not throw when invoked without a prior AcquireAsync for the given key, and remains safe to call multiple times after a single successful acquire.

[Test]
public Task ReleaseAsync_DoesNotThrow_WhenCalledWithoutPriorAcquire()

Returns

Task

ReleaseAsync_MakesSemaphoreAvailableForNextAcquire()

Verifies that calling ReleaseAsync on a semaphore provider restores availability, allowing a subsequent AcquireAsync for the same key to succeed and the semaphore's CurrentCount to transition back to its released value.

[Test]
public Task ReleaseAsync_MakesSemaphoreAvailableForNextAcquire()

Returns

Task

SetUp()

Initializes a fresh InMemoryLockProvider instance for the test fixture, ensuring each test starts with a clean, isolated provider state.

[SetUp]
public void SetUp()