=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===

This commit is contained in:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
@@ -17,6 +17,7 @@ namespace adas_core.Test.Services;
/// <summary>
/// Provides a fake implementation of the <see cref="ILockProvider"/> interface, typically used as a test double or non-functional placeholder.
/// </summary>
/// <!-- aidoc:v1 sig=861367a -->
public class FakeLockProvider : ILockProvider
{
/// <summary>
@@ -26,11 +27,13 @@ public class FakeLockProvider : ILockProvider
/// <param name="key">The identifier of the resource to acquire.</param>
/// <param name="timeout">The maximum time to wait for the resource to become available.</param>
/// <returns>A <see cref="Task{TResult}"/> that always completes with <c>true</c>, indicating the resource was acquired.</returns>
/// <!-- aidoc:v1 sig=c012d6a -->
public Task<bool> AcquireAsync(string key, TimeSpan timeout) => Task.FromResult(true);
/// <summary>
/// Releases the resource associated with the specified key. This implementation completes immediately without performing any additional operation.
/// </summary>
/// <param name="key">The identifier of the resource to release.</param>
/// <!-- aidoc:v1 sig=34ce6e6 -->
public Task ReleaseAsync(string key) => Task.CompletedTask;
}
@@ -40,6 +43,7 @@ public class FakeLockProvider : ILockProvider
/// <remarks>
/// Inherits all members from <see cref="LockManagerService"/> and is intended to be used in place of the real service when actual locking functionality is not required.
/// </remarks>
/// <!-- aidoc:v1 sig=912ee25 -->
public class FakeLockManagerService : LockManagerService
{
/// <summary>
@@ -60,6 +64,7 @@ public class FakeLockManagerService : LockManagerService
/// <remarks>
/// This class combines the inheritance of <see cref="RedisService"/> with the contract of <see cref="ICacheService"/>, allowing it to stand in for a real Redis-backed cache during unit tests or development.
/// </remarks>
/// <!-- aidoc:v1 sig=8effc11 -->
public class FakeRedisService : RedisService, ICacheService
{
public bool WasCalled { get; private set; }
@@ -86,6 +91,7 @@ public class FakeRedisService : RedisService, ICacheService
/// <param name="ttl">An optional time-to-live duration for the cached entry. Not used in this implementation.</param>
/// <param name="cancellationToken">A token to observe for cancellation requests. Not used in this implementation.</param>
/// <returns>A task that represents the asynchronous operation, containing the object produced by the factory.</returns>
/// <!-- aidoc:v1 sig=f7027e3 body=b366c2a -->
Task<T> ICacheService.GetOrSetObjectAsync<T>(
string key,
Func<Task<T>> factory,
@@ -107,6 +113,7 @@ public class FakeRedisService : RedisService, ICacheService
/// <param name="ttl">An optional time-to-live duration for the cached entry.</param>
/// <param name="cancellationToken">The token used to cancel the asynchronous operation.</param>
/// <returns>The value of type <typeparamref name="T"/> produced by the <paramref name="factory"/> delegate.</returns>
/// <!-- aidoc:v1 sig=efeef03 body=0bb8f50 -->
Task<T> ICacheService.GetOrSetObjectAsync<T>(
GroupedField groupedField,
ObjectId patientId,
@@ -126,6 +133,7 @@ public class FakeRedisService : RedisService, ICacheService
/// <remarks>
/// This class combines inheritance from the concrete <see cref="CacheService"/> base class with the <see cref="ICacheService"/> contract, allowing it to be used wherever an <see cref="ICacheService"/> is required.
/// </remarks>
/// <!-- aidoc:v1 sig=db2971f -->
public class FakeCacheService : CacheService, ICacheService
{
public bool WasCalled { get; private set; }
@@ -148,6 +156,15 @@ public class FakeCacheService : CacheService, ICacheService
/// <param name="cancellationToken">Token to cancel the operation; ignored by this implementation.</param>
/// <returns>The <see cref="Task{T}"/> produced by invoking <paramref name="factory"/>.</returns>
/// <!-- aidoc:v1 sig=f7027e3 body=b366c2a -->
/// <summary>
/// Explicit <see cref="ICacheService"/> implementation that always invokes <paramref name="factory"/> and ignores <paramref name="ttl"/> and <paramref name="cancellationToken"/>, effectively bypassing the cache and returning the value freshly produced for the supplied <paramref name="key"/>.
/// </summary>
/// <param name="key">The cache key identifying the requested entry.</param>
/// <param name="factory">The asynchronous delegate invoked to produce the value.</param>
/// <param name="ttl">The optional cache lifetime. Not applied by this implementation.</param>
/// <param name="cancellationToken">The token used to cancel the operation. Not observed by this implementation.</param>
/// <returns>A <see cref="Task{T}"/> that completes with the value returned by <paramref name="factory"/>.</returns>
/// <!-- aidoc:v1 sig=f7027e3 body=b366c2a -->
Task<T> ICacheService.GetOrSetObjectAsync<T>(
string key,
Func<Task<T>> factory,
@@ -170,6 +187,18 @@ public class FakeCacheService : CacheService, ICacheService
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the operation.</param>
/// <returns>A <see cref="Task{T}"/> that resolves to the value returned by <paramref name="factory"/>.</returns>
/// <!-- aidoc:v1 sig=efeef03 body=0bb8f50 -->
/// <summary>
/// Test implementation of <see cref="ICacheService.GetOrSetObjectAsync{T}"/> that bypasses caching
/// and directly invokes the supplied <paramref name="factory"/> delegate, recording the call via the
/// WasCalled flag for verification purposes.
/// </summary>
/// <param name="groupedField">The <see cref="GroupedField"/> identifying the group context for the cached or computed object.</param>
/// <param name="patientId">The <see cref="ObjectId"/> of the patient whose data is being retrieved.</param>
/// <param name="factory">The <see cref="Func{Task{T}}"/> delegate invoked to produce the result.</param>
/// <param name="ttl">Optional time-to-live duration; ignored by this implementation.</param>
/// <param name="cancellationToken">Token to observe for cancellation; ignored by this implementation.</param>
/// <returns>The <see cref="Task{T}"/> produced by invoking <paramref name="factory"/>.</returns>
/// <!-- aidoc:v1 sig=efeef03 body=0bb8f50 -->
Task<T> ICacheService.GetOrSetObjectAsync<T>(
GroupedField groupedField,
ObjectId patientId,
@@ -189,6 +218,7 @@ public class FakeCacheService : CacheService, ICacheService
/// <remarks>
/// This class inherits from <see cref="NoCacheService"/> and implements the <see cref="ICacheService"/> interface, providing a non-functional cache suitable for unit tests or environments where caching should be bypassed.
/// </remarks>
/// <!-- aidoc:v1 sig=801fd16 -->
public class FakeNoCacheService : NoCacheService, ICacheService
{
public bool WasCalled { get; private set; }
@@ -234,6 +264,7 @@ public class CacheDispatcherTest
/// <summary>
/// Initializes the test environment by instantiating fake implementations of the Redis, in-memory, and no-op cache services, along with default <see cref="CacheSettings"/>, and constructs a <see cref="CacheDispatcher"/> under test using these dependencies.
/// </summary>
/// <!-- aidoc:v1 sig=d8eb19f body=9827af1 -->
[SetUp]
public void SetUp()
{
@@ -358,6 +389,7 @@ public class CacheDispatcherTest
/// <summary>
/// Verifies that <see cref="CacheKeyClassifier.Classify"/> returns <see cref="CacheEnum.EntityType.Unknown"/> when the provided cache key does not start with any recognized prefix.
/// </summary>
/// <!-- aidoc:v1 sig=60a34b6 body=6a7aecd -->
[Test]
public void Classify_ReturnsUnknown_ForUnrecognizedPrefix()
{