Table of Contents

Class CacheServiceTest

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

Methods

CleanCache_RemovesAllKeys_AndFactoryIsInvokedAfterClean()

Verifies that CleanCache removes all entries from the cache, causing subsequent GetOrSetObjectAsync calls to invoke the provided factory delegate to repopulate the value.

[Test]
public Task CleanCache_RemovesAllKeys_AndFactoryIsInvokedAfterClean()

Returns

Task

DeleteByPatternAsync_RemovesMatchingKeys_AndKeepsNonMatchingKeys()

Verifies that DeleteByPatternAsync removes only the cache entries whose keys match the supplied pattern while preserving unrelated keys that do not match.

[Test]
public Task DeleteByPatternAsync_RemovesMatchingKeys_AndKeepsNonMatchingKeys()

Returns

Task

DeleteObjectAsync_RemovesKey_AndFactoryIsInvokedOnNextCall()

Verifies that calling DeleteObjectAsync removes the stored value for the given key, and that the next call to GetOrSetObjectAsync invokes the factory delegate to produce a new value instead of returning a previously cached one.

[Test]
public Task DeleteObjectAsync_RemovesKey_AndFactoryIsInvokedOnNextCall()

Returns

Task

GetOrSetObjectAsync_DoesNotCacheNullResult_AndInvokesFactoryOnSubsequentCalls()

Verifies that GetOrSetObjectAsync does not cache null results, ensuring the factory delegate is re-invoked on subsequent calls for the same key when the previously produced value was null.

[Test]
public Task GetOrSetObjectAsync_DoesNotCacheNullResult_AndInvokesFactoryOnSubsequentCalls()

Returns

Task

GetOrSetObjectAsync_InvokesFactory_StoresResult_AndDoesNotInvokeAgainOnSecondCall()

Verifies that GetOrSetObjectAsync invokes the supplied factory on the first call, persists the produced value, and on subsequent calls returns the cached value without invoking the factory again.

[Test]
public Task GetOrSetObjectAsync_InvokesFactory_StoresResult_AndDoesNotInvokeAgainOnSecondCall()

Returns

Task

GetOrSetObjectAsync_ReturnsCachedValue_AndDoesNotInvokeFactory_WhenKeyAlreadyExists()

[Test]
public Task GetOrSetObjectAsync_ReturnsCachedValue_AndDoesNotInvokeFactory_WhenKeyAlreadyExists()

Returns

Task

GetOrSetObjectAsync_SecondCheckInLock_PreventsFactoryExecution_WhenValueAlreadyInsertedByFirstThread()

Verifies that when two threads call GetOrSetObjectAsync concurrently for the same key, the second thread does not invoke its factory if the first thread has already inserted the value, and both threads receive the value produced by the first thread's factory.

[Test]
public Task GetOrSetObjectAsync_SecondCheckInLock_PreventsFactoryExecution_WhenValueAlreadyInsertedByFirstThread()

Returns

Task

SetUp()

Initializes the test environment by creating a LockManagerService with a mock logger and an in-memory lock provider, and instantiating the CacheService under test with that lock manager.

[SetUp]
public void SetUp()