Table of Contents

Class RedisServiceTest

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

Methods

GetObjectAsync_CallsKeyExpire_WhenUpdateExpirationIsTrue()

Verifies that GetObjectAsync calls the underlying Redis KeyExpire command with the configured TTL when the updateExpiration flag is set to true, ensuring cache entries are refreshed upon a successful hit.

[Test]
public Task GetObjectAsync_CallsKeyExpire_WhenUpdateExpirationIsTrue()

Returns

Task

GetObjectAsync_DoesNotCallKeyExpire_WhenUpdateExpirationIsFalse()

Verifies that GetObjectAsync does not invoke the Redis key expiration command when the caller explicitly requests that the existing expiration be left unchanged.

[Test]
public Task GetObjectAsync_DoesNotCallKeyExpire_WhenUpdateExpirationIsFalse()

Returns

Task

GetObjectAsync_ReturnsObject_AndSkipsKeyExpire_WhenUpdateExpirationFalse()

Verifies that GetObjectAsync successfully retrieves and deserializes the stored object while skipping the key-expiration refresh when updateExpiration is set to false, ensuring KeyExpire is never invoked.

[Test]
public Task GetObjectAsync_ReturnsObject_AndSkipsKeyExpire_WhenUpdateExpirationFalse()

Returns

Task

GetOrSetObjectAsync_DoesNotPersist_WhenFactoryReturnsNull()

Verifies that when the cache lookup returns no value and the factory delegate produces null, the method returns null and does not persist any value to the underlying cache store.

[Test]
public Task GetOrSetObjectAsync_DoesNotPersist_WhenFactoryReturnsNull()

Returns

Task

GetOrSetObjectAsync_ExecutesFactory_WhenRedisUnavailable()

Verifies that GetOrSetObjectAsync invokes the supplied factory when Redis is unavailable, returning the factory's result without attempting any Redis read or write operations.

[Test]
public Task GetOrSetObjectAsync_ExecutesFactory_WhenRedisUnavailable()

Returns

Task

GetOrSetObjectAsync_InvokesFactoryAndPersists_WhenCacheMiss()

Verifies that GetOrSetObjectAsync invokes the supplied factory and persists the resulting object to Redis with the configured TTL when the cache lookup returns a miss (i.e., the stored value is null). Ensures the factory delegate is executed, the deserialized value matches the factory output, and the object is written to cache with the expected expiration.

[Test]
public Task GetOrSetObjectAsync_InvokesFactoryAndPersists_WhenCacheMiss()

Returns

Task

GetOrSetObjectAsync_ReturnsCachedObject_WhenRedisHit()

Verifies that GetOrSetObjectAsync returns the cached object deserialized from Redis when a value is present in the cache, without invoking the factory delegate and without attempting to write back to Redis.

[Test]
public Task GetOrSetObjectAsync_ReturnsCachedObject_WhenRedisHit()

Returns

Task

SetObjectAsync_SerializesToJson_AndPersistsWithEntityTtl()

Verifies that SetObjectAsync serializes the supplied object to JSON and persists it in Redis with the entity-specific TTL (600 seconds) configured for the "Patients" entity in CacheSettings.

[Test]
public Task SetObjectAsync_SerializesToJson_AndPersistsWithEntityTtl()

Returns

Task

SetUp()

Initializes test dependencies before each test execution by creating a mock StackExchange.Redis.IDatabase instance and instantiating the LockManagerService with a mocked logger and an in-memory lock provider.

[SetUp]
public void SetUp()