=== 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:
@@ -18,6 +18,7 @@ namespace adas_core.Test.Services;
|
||||
/// <summary>
|
||||
/// Contains unit tests for verifying the behavior of the <see cref="AdmissionService"/> class.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0c8cbc0 -->
|
||||
public class AdmissionServiceTest
|
||||
{
|
||||
private Mock<IAdmissionRepository> _admissionRepositoryMock;
|
||||
@@ -89,6 +90,7 @@ public class AdmissionServiceTest
|
||||
/// Verifies that the admission service successfully deletes a valid admission by ensuring the repository's
|
||||
/// Delete operation is invoked exactly once for the corresponding admission identifier.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ff6349a body=41733f5 -->
|
||||
[Test]
|
||||
public async Task DeleteAdmissionAsync_ValidAdmission_DeletesSuccessfully()
|
||||
{
|
||||
@@ -109,6 +111,7 @@ public class AdmissionServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>DeleteAdmissionByIdAsync</c> successfully deletes an admission when it exists in the repository, by ensuring the repository's <c>Delete</c> method is invoked exactly once for the given admission identifier.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ca0aebd body=1a986c5 -->
|
||||
[Test]
|
||||
public async Task DeleteAdmissionByIdAsync_AdmissionExists_DeletesSuccessfully()
|
||||
{
|
||||
@@ -131,6 +134,7 @@ public class AdmissionServiceTest
|
||||
/// associated patient location (unit, bed, and room) when the admission exists in the repository and the
|
||||
/// corresponding point of care is successfully resolved.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8868841 body=7a047e6 -->
|
||||
[Test]
|
||||
public async Task GetAdmissionByIdAsync_AdmissionExists_ReturnsAdmissionWithPatientLocation()
|
||||
{
|
||||
@@ -160,6 +164,7 @@ public class AdmissionServiceTest
|
||||
/// Verifies that GetAdmissionsAsync returns admissions enriched with their associated patient location details
|
||||
/// retrieved from the point of care service.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=13eea4d body=5097039 -->
|
||||
[Test]
|
||||
public async Task GetAdmissionsAsync_ReturnsAdmissionsWithPatientLocations()
|
||||
{
|
||||
@@ -233,6 +238,7 @@ public class AdmissionServiceTest
|
||||
/// invoking the repository's Update method and retrieving point-of-care information for both the new and the
|
||||
/// previous point of care associated with the admission.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=947fcb9 body=5539a54 -->
|
||||
[Test]
|
||||
public async Task UpdateAdmissionAsync_WhenAdmissionExists_UpdatesAdmission()
|
||||
{
|
||||
@@ -287,6 +293,7 @@ public class AdmissionServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that admitting a patient with a valid admission—where the associated unit is found and the point of care matches—results in a new patient being inserted.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e2d99bb body=d8e5f1d -->
|
||||
[Test]
|
||||
public async Task AdmitPatient_WithValidAdmission_CreatesPatientAndDeletesAdmission()
|
||||
{
|
||||
@@ -315,6 +322,7 @@ public class AdmissionServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that GetAdmissionByLocation returns the expected list of admissions when a matching patient location is found, confirming the service correctly retrieves results from the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1bd035d body=629b781 -->
|
||||
[Test]
|
||||
public async Task GetAdmissionByLocation_LocationExists_ReturnsAdmissions()
|
||||
{
|
||||
@@ -345,6 +353,7 @@ public class AdmissionServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="AdmissionService.GetAdmissionByLocation"/> returns an empty result when the requested location does not exist, simulating the not-found scenario by having the repository throw an exception.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3fa7d19 body=0413056 -->
|
||||
[Test]
|
||||
public async Task GetAdmissionByLocation_LocationNotFound_ReturnsNull()
|
||||
{
|
||||
@@ -371,6 +380,7 @@ public class AdmissionServiceTest
|
||||
/// <c>GetAdmissionByPointOfCareId</c> are enriched with patient location details (unit name, bed, and room)
|
||||
/// retrieved from the corresponding Point of Care entity.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9e8788f body=f355f5f -->
|
||||
[Test]
|
||||
public async Task GetAdmissionByPointOfCareId_POCExists_ReturnsAdmissionsWithLocation()
|
||||
{
|
||||
@@ -414,6 +424,7 @@ public class AdmissionServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="AdmissionService.GetAdmissionByPointOfCareId"/> returns an empty result when the underlying repository throws an exception while attempting to find an admission by point of care id.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=38a42b6 body=272b246 -->
|
||||
[Test]
|
||||
public async Task GetAdmissionByPointOfCareId_POCNotFound_ReturnsNull()
|
||||
{
|
||||
@@ -434,6 +445,7 @@ public class AdmissionServiceTest
|
||||
/// Verifies that <see cref="AdmissionService.GetAdmissionByUnitIdWithOutPoC"/> returns the expected list of admissions
|
||||
/// when a valid unit identifier is provided.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=991c53f body=6e3b77c -->
|
||||
[Test]
|
||||
public async Task GetAdmissionByUnitIdWithOutPoC_UnitIdExists_ReturnsAdmissions()
|
||||
{
|
||||
@@ -462,6 +474,8 @@ public class AdmissionServiceTest
|
||||
/// throws an exception while looking up the given unit identifier.
|
||||
/// </summary>
|
||||
/// <param name="unitId">The identifier of the unit whose admission record is being requested.</param>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=extra_param
|
||||
/// "The <param name=\"unitId\"> tag documents a parameter that does not exist on the test method; unitId is a local variable, not a method parameter." -->
|
||||
[Test]
|
||||
public async Task GetAdmissionByUnitIdWithOutPoC_UnitIdNotFound_ReturnsNull()
|
||||
{
|
||||
@@ -580,6 +594,7 @@ public class AdmissionServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that InsertAdmission throws a NotFoundException and performs no insert or update operations when a required associated resource is not found while processing a valid admission.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bdfda99 body=4d28639 -->
|
||||
[Test]
|
||||
public async Task InsertAdmission_ValidAdmission_InsertsSuccessfullyWithUser()
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace adas_core.Test.Services;
|
||||
/// <summary>
|
||||
/// Contains unit tests for verifying the behavior and functionality of the <see cref="AlarmService"/> class.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c43823a -->
|
||||
public class AlarmServiceTest
|
||||
{
|
||||
private readonly Mock<IAlarmRepository> _alarmRepositoryMock;
|
||||
@@ -121,6 +122,7 @@ public class AlarmServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ORU_R40 type request is processed without any alarms, the patient is located but the observation is not persisted.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a5366da body=1b7e9c5 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Oru_R40_Type_Without_Alarms_Dont_Insert()
|
||||
{
|
||||
@@ -151,6 +153,7 @@ public class AlarmServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="AlarmService.ProcessAlarmObservations"/> inserts the provided alarm observations into the alarm repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=055d260 body=8ccc248 -->
|
||||
[Test]
|
||||
public async Task ProcessAlarmObservations_Should_Insert_Alarm_Observations()
|
||||
{
|
||||
@@ -183,6 +186,7 @@ public class AlarmServiceTest
|
||||
/// (coding system "ADAS_EVENT", description "EVT_LO and EVT_EXTR_LO"), the alarm service does not insert a new observation,
|
||||
/// as indicated by the verification that <c>InsertObservation</c> is never invoked.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=108393a body=30d7b84 -->
|
||||
[Test]
|
||||
public async Task CheckObservationAlarm_Alarm_EventPEEP_PEEP_bajo_create_Event()
|
||||
{
|
||||
@@ -211,6 +215,7 @@ public class AlarmServiceTest
|
||||
/// observation with the original value preserved (e.g., "PEEP High") while the alarm
|
||||
/// configuration handles the red beacon signaling.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=eb5bfdd body=09dd5c4 -->
|
||||
[Test]
|
||||
public async Task CheckObservationAlarm_Should_Launch_Red_Alarm_And_Set_BeaconColor_Red()
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ public class CacheServiceTest
|
||||
/// Initializes the test environment by creating a <see cref="LockManagerService"/> with a mock logger
|
||||
/// and an in-memory lock provider, and instantiating the <see cref="CacheService"/> under test with that lock manager.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d8eb19f body=0002dc3 -->
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -55,6 +56,7 @@ public class CacheServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>GetOrSetObjectAsync</c> 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.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9730504 body=5d35764 -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_InvokesFactory_StoresResult_AndDoesNotInvokeAgainOnSecondCall()
|
||||
{
|
||||
@@ -89,6 +91,7 @@ public class CacheServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>GetOrSetObjectAsync</c> does not cache <see langword="null"/> results, ensuring the factory delegate is re-invoked on subsequent calls for the same key when the previously produced value was <see langword="null"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bb0d5c2 body=179c9ee -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_DoesNotCacheNullResult_AndInvokesFactoryOnSubsequentCalls()
|
||||
{
|
||||
@@ -118,6 +121,7 @@ public class CacheServiceTest
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6a067fe body=858fc91 -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_SecondCheckInLock_PreventsFactoryExecution_WhenValueAlreadyInsertedByFirstThread()
|
||||
{
|
||||
@@ -161,6 +165,7 @@ public class CacheServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that calling <c>DeleteObjectAsync</c> removes the stored value for the given key, and that the next call to <c>GetOrSetObjectAsync</c> invokes the factory delegate to produce a new value instead of returning a previously cached one.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c88be79 body=aaf8770 -->
|
||||
[Test]
|
||||
public async Task DeleteObjectAsync_RemovesKey_AndFactoryIsInvokedOnNextCall()
|
||||
{
|
||||
@@ -188,6 +193,7 @@ public class CacheServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>DeleteByPatternAsync</c> removes only the cache entries whose keys match the supplied pattern while preserving unrelated keys that do not match.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=395241c body=7523f89 -->
|
||||
[Test]
|
||||
public async Task DeleteByPatternAsync_RemovesMatchingKeys_AndKeepsNonMatchingKeys()
|
||||
{
|
||||
@@ -214,6 +220,7 @@ public class CacheServiceTest
|
||||
/// Verifies that <c>CleanCache</c> removes all entries from the cache, causing subsequent
|
||||
/// <c>GetOrSetObjectAsync</c> calls to invoke the provided factory delegate to repopulate the value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3336c2b body=de2514b -->
|
||||
[Test]
|
||||
public async Task CleanCache_RemovesAllKeys_AndFactoryIsInvokedAfterClean()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ internal class CameraServiceTest
|
||||
/// <summary>
|
||||
/// NUnit <see cref="SetUpAttribute"/> method executed before each test to initialize shared test state, such as camera configuration dictionaries, mocked camera and logger services, and a mocked subscribers service. Currently all initialization logic is commented out, so the method performs no setup actions.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=4448e1d -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -50,6 +51,8 @@ internal class CameraServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the <c>MaskStream</c> operation on the camera service returns a valid response when invoked with activation and coordinate parameters against the configured camera settings. Covers the scenario where the underlying grab response is null, ensuring the service still produces a non-null response with the expected status code and content.
|
||||
/// </summary>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=stale_summary
|
||||
/// "The entire method body is commented out, so no verification, assertions, or behavior described in the summary actually executes; the test has been effectively removed." -->
|
||||
public void MaskStream_Return_Ok()
|
||||
{
|
||||
//bool activate = true;
|
||||
|
||||
@@ -83,6 +83,7 @@ public class ConfigObservationServiceTest
|
||||
/// Configures a default authenticated <see cref="ClaimsPrincipal"/> in the HTTP context and sets the cache mocks to bypass caching by executing the factory function directly,
|
||||
/// ensuring repository calls are invoked during tests.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=baa71ba -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -144,6 +145,8 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that querying a patient observation by <c>CodingSystem</c> only, without specifying a code or name, returns a null result.
|
||||
/// </summary>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "The summary states the query is performed 'without specifying a code or name', but the test code explicitly sets Code = \"Pump_X\" and Name = \"Alarm_Pump_X\" on the PatientObservation before calling _service.Get(obs)." -->
|
||||
[Test]
|
||||
public async Task Get_config_observation_item_by_codingSystem_only_return_null()
|
||||
{
|
||||
@@ -163,6 +166,7 @@ public class ConfigObservationServiceTest
|
||||
/// Verifies that <c>Get</c> returns the matching patient observation configuration for a given observation identified by its code and coding system.
|
||||
/// Asserts that the resolved item is not null and that the displayed name is mapped from the configured lookup to the expected localized value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d32a79d body=97b6327 -->
|
||||
[Test]
|
||||
public async Task Get_config_observation_item_by_code_and_codingSystem()
|
||||
{
|
||||
@@ -186,6 +190,7 @@ public class ConfigObservationServiceTest
|
||||
/// matching the requested observation against the list returned by the repository and returning
|
||||
/// the item with the expected name.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3d7c0ca body=615f166 -->
|
||||
[Test]
|
||||
public async Task Get_config_observation_item_by_name()
|
||||
{
|
||||
@@ -201,6 +206,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the service returns null when a patient observation item is requested by a name that does not exist in the configuration list.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fa14228 body=beae3aa -->
|
||||
[Test]
|
||||
public async Task Get_config_observation_item_by_name_not_exist_returns_null()
|
||||
{
|
||||
@@ -216,6 +222,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the service retrieves the correct configuration by matching both the observation code with its coding system and the parent data code with its coding system, returning the configuration named "ph".
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2711221 body=baf8942 -->
|
||||
[Test]
|
||||
public async Task Get_config_by_code_and_parent()
|
||||
{
|
||||
@@ -241,6 +248,7 @@ public class ConfigObservationServiceTest
|
||||
/// Verifies that the mapping service returns <c>null</c> when the observation name is unknown
|
||||
/// and the configuration is set to ignore unknown observations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b604759 body=1c3599d -->
|
||||
[Test]
|
||||
public async Task Map_unknown_ignore_true_returns_null()
|
||||
{
|
||||
@@ -257,6 +265,7 @@ public class ConfigObservationServiceTest
|
||||
/// the <c>Map</c> method returns the original observation as-is when no matching record is found
|
||||
/// in the repository, rather than discarding it as an unknown observation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bb05709 body=c204c4b -->
|
||||
[Test]
|
||||
public async Task Map_unknown_ignore_false_returns_obs()
|
||||
{
|
||||
@@ -273,6 +282,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that mapping a patient observation with a value of 14 results in an "Ok" status, confirming the threshold mapping logic returns the expected outcome.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=81e9217 body=d5f8b5a -->
|
||||
[Test]
|
||||
public async Task Map_threshold_Ok()
|
||||
{
|
||||
@@ -293,6 +303,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Tests that the Map method returns a Warning status when a patient observation value exceeds the configured threshold.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=62b87c5 body=8312d29 -->
|
||||
[Test]
|
||||
public async Task Map_threshold_Warning()
|
||||
{
|
||||
@@ -313,6 +324,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with a SOFA score of 9 through the configured service results in a result with an <see cref="StatusEnum.Type.Alert"/> status.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b9d47f9 body=ff5f81e -->
|
||||
[Test]
|
||||
public async Task Map_threshold_Alert()
|
||||
{
|
||||
@@ -334,6 +346,7 @@ public class ConfigObservationServiceTest
|
||||
/// Verifies that mapping a parent <see cref="PatientObservation"/> returns an <see cref="StatusEnum.Type.Ok"/> status
|
||||
/// when the repository successfully locates the configuration by identifier.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ba42824 body=c7bbf55 -->
|
||||
[Test]
|
||||
public async Task Map_parent_ok()
|
||||
{
|
||||
@@ -354,6 +367,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>UpdateConfig</c> successfully updates an existing configuration and returns the updated <see cref="ConfigObservation"/> with the new name.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=18d4b11 body=f7f80a4 -->
|
||||
[Test]
|
||||
public async Task UpdateConfig_ok()
|
||||
{
|
||||
@@ -376,6 +390,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>UpdateConfig</c> throws a <see cref="NotFoundException"/> when the target <c>ConfigObservation</c> cannot be found by its identifier.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=470341f body=33e9665 -->
|
||||
[Test]
|
||||
public async Task UpdateConfig_notfound()
|
||||
{
|
||||
@@ -392,6 +407,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the <c>CreateConfig</c> service method successfully inserts the provided configuration and returns the expected result.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4c4fb2f body=19b37b8 -->
|
||||
[Test]
|
||||
public async Task CreateConfig_ok()
|
||||
{
|
||||
@@ -405,6 +421,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="BadRequestException"/> is thrown when attempting to create a configuration that already exists.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ea4710c body=04477ed -->
|
||||
[Test]
|
||||
public void CreateConfig_duplicate_throws()
|
||||
{
|
||||
@@ -420,6 +437,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that RemoveConfigItem successfully removes a configuration item and returns the deleted entity when the repository finds and deletes it.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=30c283f body=7951323 -->
|
||||
[Test]
|
||||
public async Task RemoveConfigItem_ok()
|
||||
{
|
||||
@@ -436,6 +454,7 @@ public class ConfigObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>RemoveConfigItem</c> returns <c>null</c> when the underlying delete operation on the repository yields no result, simulating the case where the configuration item does not exist.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=87b0794 body=76439aa -->
|
||||
[Test]
|
||||
public async Task RemoveConfigItem_null()
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ public class ConfigPumpsServiceTest
|
||||
/// <summary>
|
||||
/// Initializes the test environment by creating mock dependencies and instantiating the <see cref="ConfigPumpsService"/> under test.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=4e72b76 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -72,6 +73,7 @@ public class ConfigPumpsServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="ConfigPumpsService.Map"/> method returns the same <see cref="PumpObservation"/> instance unchanged when the <c>ConfigPumpsRequired</c> option is set to <c>false</c>, bypassing any pump configuration lookup or transformation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1d5bff3 body=48fe32c -->
|
||||
[Test]
|
||||
public async Task Map_configPumpsRequired_false_Return_same_pump()
|
||||
{
|
||||
@@ -100,6 +102,7 @@ public class ConfigPumpsServiceTest
|
||||
/// Verifies that when pump configuration is required and the pump has no alarm type,
|
||||
/// the <c>Map</c> method returns the same pump instance unchanged.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3192070 body=bd61ede -->
|
||||
[Test]
|
||||
public async Task Map_not_alarmType_Return_same_pump()
|
||||
{
|
||||
@@ -120,6 +123,7 @@ public class ConfigPumpsServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="ConfigPumpsService.Map"/> method returns the original <see cref="PumpObservation"/> unchanged when the configuration pump item is empty, ensuring that no <c>UiConfiguration</c> is assigned in that case.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8a185e9 body=db91573 -->
|
||||
[Test]
|
||||
public async Task Map_Not_uiConfiguration_Return_same_pump()
|
||||
{
|
||||
@@ -156,6 +160,7 @@ public class ConfigPumpsServiceTest
|
||||
/// alarm type, ensuring the resulting UI configuration contains the expected label
|
||||
/// entries such as the "screenAlarmLabel" mapped to the alarm type.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=585a146 body=115a9b0 -->
|
||||
[Test]
|
||||
public async Task Map_uiConfiguration_Return_pump_uiConfiguration()
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ public class ConfigUnitsServiceTest
|
||||
/// <summary>
|
||||
/// Initializes the test dependencies and creates a new instance of <see cref="ConfigUnitsService"/> with mocked repository, options, and logger for use in unit tests.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=f4122ef -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -58,6 +59,7 @@ public class ConfigUnitsServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when <c>ConfigUnitsRequired</c> is set to <c>false</c>, the <see cref="ConfigUnitsService.Map"/> method returns the same observation instance without applying any unit mapping or transformation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bab3791 body=d6d820f -->
|
||||
[Test]
|
||||
public async Task Map_configUnitsRequired_false_Return_same_obs()
|
||||
{
|
||||
@@ -84,6 +86,7 @@ public class ConfigUnitsServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that mapping a patient observation that does not contain units returns the same observation unchanged, confirming the mapping logic preserves the original data when no unit conversion is applicable.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fc6d0dc body=239be85 -->
|
||||
[Test]
|
||||
public async Task Map_not_units_Return_same_obs()
|
||||
{
|
||||
@@ -105,6 +108,7 @@ public class ConfigUnitsServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the Map method returns the original observation unchanged with a null Units property when configuration units are required and no matching config unit is found for the observation's code.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7e98721 body=91ddc62 -->
|
||||
[Test]
|
||||
public async Task Map_Not_Find_Config_Return_same_obs()
|
||||
{
|
||||
@@ -140,6 +144,7 @@ public class ConfigUnitsServiceTest
|
||||
/// Verifies that Map returns the configured unit value for a patient observation when
|
||||
/// ConfigUnitsRequired is enabled and a matching config unit is found in the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f7a66e6 body=4f13f04 -->
|
||||
[Test]
|
||||
public async Task Map_configUnits_Return_obs_ConfigUnit()
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ public class DiagnosisServiceTest
|
||||
/// <summary>
|
||||
/// Initializes the mocked dependencies (patient, diagnosis, unit, audit, subscribers and calculated observations services along with their repositories) and constructs the <see cref="DiagnosisService"/> instance under test.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=00b1d4d -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -148,6 +149,7 @@ public class DiagnosisServiceTest
|
||||
/// Verifies that <c>SaveRequest</c> does not insert a diagnosis when the patient referenced by the <see cref="ApiRequest"/> cannot be found.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=8c3ffda body=ba42756 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Not_FindPatient_Return_not_insert()
|
||||
{
|
||||
@@ -172,6 +174,12 @@ public class DiagnosisServiceTest
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request containing the patient and observation data being evaluated.</param>
|
||||
/// <param name="null">Reserved parameter passed to <c>SaveRequest</c> as a null value.</param>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "The summary states SaveRequest is invoked when the ApiRequest is 'not considered an observation request', but the test setup explicitly populates ObservationData (Code, CodingSystem, Value, Text, Time)." -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=stale_summary
|
||||
/// "The summary claims 'observations must be present to trigger a database insertion', yet the test contains a fully populated ObservationData and still expects InsertOneAsync to never be called." -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=extra_param
|
||||
/// "The test method takes no parameters, but the documentation declares <param name='apiRequest'> and <param name='null'>, describing arguments passed to SaveRequest rather than test parameters." -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Not_Observations_Return_not_insert()
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace adas_core.Test.Services;
|
||||
/// <summary>
|
||||
/// Provides unit tests for the <see cref="DischargeService"/> class, verifying the behavior and correctness of discharge-related operations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=400fd1a -->
|
||||
public class DischargeServiceTest
|
||||
{
|
||||
private readonly Mock<ILocalAuditService> _auditServiceMock = new();
|
||||
@@ -34,6 +35,7 @@ public class DischargeServiceTest
|
||||
/// <summary>
|
||||
/// Sets up the test environment by creating a mock authenticated user context and instantiating the <see cref="DischargeService"/> with its required dependencies for use in unit tests.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=c3b979f -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -66,6 +68,8 @@ public class DischargeServiceTest
|
||||
/// when it exists in the repository.
|
||||
/// </summary>
|
||||
/// <param name="discharge">The discharge entity expected to be deleted; its identifier is used to invoke the repository delete operation.</param>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=extra_param
|
||||
/// "The test method takes no parameters, but the documentation includes a <param name=\"discharge\"> tag. The discharge is an argument passed to the production method being tested, not a parameter of the test itself." -->
|
||||
[Test]
|
||||
public async Task DeleteDischargeAsync_WhenDischargeExists_DeletesDischarge()
|
||||
{
|
||||
@@ -100,6 +104,7 @@ public class DischargeServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="DischargeService.GetDischargeByIdAsync"/> throws a <see cref="NotFoundException"/> when the requested discharge is not found.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=52f2a9a body=86f9d19 -->
|
||||
[Test]
|
||||
public void GetDischargeByIdAsync_WhenExceptionOccurs_ReturnsNullAndLogsError()
|
||||
{
|
||||
@@ -114,6 +119,7 @@ public class DischargeServiceTest
|
||||
/// Verifies that the discharge service returns the expected discharges retrieved from the repository when the underlying repository call completes successfully without exceptions.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=11f6fa6 body=746f877 -->
|
||||
[Test]
|
||||
public async Task GetDischargesAsync_WhenNoException_ReturnsDischarges()
|
||||
{
|
||||
@@ -150,6 +156,7 @@ public class DischargeServiceTest
|
||||
/// Verifies that <see cref="DischargeService.InsertDischarge"/> returns the inserted discharge
|
||||
/// when the underlying repository successfully completes the insertion and the entity can be retrieved by its identifier.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f69e0b9 body=aed5a93 -->
|
||||
[Test]
|
||||
public async Task InsertDischarge_WhenInsertionSuccessful_ReturnsInsertedDischarge()
|
||||
{
|
||||
@@ -169,6 +176,7 @@ public class DischargeServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="DischargeService.InsertDischarge"/> handles repository insertion failures by propagating the exception thrown by the underlying data store.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b44150e body=8660eb8 -->
|
||||
[Test]
|
||||
public void InsertDischarge_WhenInsertionFails_ReturnsNullAndLogsError()
|
||||
{
|
||||
@@ -186,6 +194,7 @@ public class DischargeServiceTest
|
||||
/// Verifies that <see cref="DischargeService.GetDischargeByLocation"/> returns the discharge
|
||||
/// retrieved from the repository when a discharge exists for the specified patient location.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a7b4f8b body=70251df -->
|
||||
[Test]
|
||||
public async Task GetDischargeByLocation_WhenDischargeExists_ReturnsDischarge()
|
||||
{
|
||||
@@ -204,6 +213,7 @@ public class DischargeServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="IDischargeService.GetDischargeByLocation"/> returns <c>null</c> when the underlying discharge repository throws an exception while retrieving the discharge record for the specified patient location.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2531264 body=4379b10 -->
|
||||
[Test]
|
||||
public async Task GetDischargeByLocation_WhenExceptionOccurs_ReturnsNullAndLogsError()
|
||||
{
|
||||
@@ -236,6 +246,7 @@ public class DischargeServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="DischargeService.GetDischargeByPointOfCareId"/> returns <c>null</c> when the underlying repository throws an exception while attempting to retrieve a discharge by its point-of-care identifier.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3c82b56 body=9141fcb -->
|
||||
[Test]
|
||||
public async Task GetDischargeByPointOfCareId_WhenExceptionOccurs_ReturnsNullAndLogsError()
|
||||
{
|
||||
|
||||
@@ -46,6 +46,7 @@ public class DisplayServiceTest
|
||||
/// Initializes mocked dependencies and configuration required to construct a <see cref="DisplayService"/> instance for unit tests.
|
||||
/// Sets up the HTTP context with a test user claim, creates default cache settings, and wires all collaborators (repositories, services, logger, permissions) into the service under test.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d8eb19f body=d0144e9 -->
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -93,6 +94,7 @@ public class DisplayServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="DisplayService.InsertOne"/> inserts a display by resolving the default configuration for its type and persisting it through the repository's insert method.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8846ed1 body=36d74d2 -->
|
||||
[Test]
|
||||
public async Task InsertOne_ShouldInsertDisplay()
|
||||
{
|
||||
@@ -121,6 +123,7 @@ public class DisplayServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="DisplayService"/> returns the expected <see cref="Display"/> instance when a matching id is provided through the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a7045b7 body=3124a14 -->
|
||||
[Test]
|
||||
public async Task GetById_ShouldReturnDisplay()
|
||||
{
|
||||
@@ -140,6 +143,7 @@ public class DisplayServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that _displayService.GetAllByUser returns an empty collection when the user name is null.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=67b03d0 body=cceeae1 -->
|
||||
[Test]
|
||||
public async Task GetAllByUser_ShouldReturnEmpty_WhenUserNameNull()
|
||||
{
|
||||
@@ -238,6 +242,7 @@ public class DisplayServiceTest
|
||||
/// from the display repository, ensuring the service correctly resolves configurations and
|
||||
/// their linked displays for the given display type.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=5eccacf body=8683226 -->
|
||||
[Test]
|
||||
public async Task GetByType_ShouldReturnDisplays()
|
||||
{
|
||||
@@ -261,6 +266,7 @@ public class DisplayServiceTest
|
||||
/// Verifies that <see cref="DisplayService.GetByType"/> returns an empty collection when no display configurations are found for the specified display type.
|
||||
/// </summary>
|
||||
/// <returns>A task that completes when the assertion confirming the empty result has been executed.</returns>
|
||||
/// <!-- aidoc:v1 sig=b325f8a body=dccb49c -->
|
||||
[Test]
|
||||
public async Task GetByType_ShouldReturnEmpty_WhenNoConfigsFound()
|
||||
{
|
||||
@@ -280,6 +286,8 @@ public class DisplayServiceTest
|
||||
/// </summary>
|
||||
/// <param name="poc">The point of care used to look up associated displays.</param>
|
||||
/// <returns>A task representing the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=extra_param
|
||||
/// "The <param name=\"poc\"> tag documents a parameter that does not exist on the test method (which takes no arguments)." -->
|
||||
[Test]
|
||||
public async Task GetByPointOfCare_ShouldReturnDisplays()
|
||||
{
|
||||
@@ -301,6 +309,7 @@ public class DisplayServiceTest
|
||||
/// Verifies that <see cref="DisplayService.GetByConfigId"/> returns the displays associated with the specified configuration ID retrieved from the repository.
|
||||
/// </summary>
|
||||
/// <returns>A task that completes when the assertion confirms the returned collection contains the expected number of displays.</returns>
|
||||
/// <!-- aidoc:v1 sig=0344410 body=2a414ec -->
|
||||
[Test]
|
||||
public async Task GetByConfigId_ShouldReturnDisplays()
|
||||
{
|
||||
@@ -321,6 +330,7 @@ public class DisplayServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="DisplayService.GetByName"/> method throws a <see cref="NotFoundException"/> when no display matching the specified name is found in the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9366b2d body=7fc914f -->
|
||||
[Test]
|
||||
public void GetByName_ShouldThrow_WhenNotFound()
|
||||
{
|
||||
@@ -337,6 +347,7 @@ public class DisplayServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>GetInfo</c> returns a <see cref="Display"/> with its associated <c>PointOfCare</c> entries populated when invoked with the "with POC" flag enabled and a valid display identifier.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0097b05 body=1dea72f -->
|
||||
[Test]
|
||||
public async Task GetInfo_ShouldReturnDisplayWithPoc()
|
||||
{
|
||||
@@ -381,6 +392,7 @@ public class DisplayServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="IDisplayService.GetByUnitId"/> returns the displays associated with the specified unit identifier when the repository contains matching records.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2c9de1f body=4dae710 -->
|
||||
[Test]
|
||||
public async Task GetByUnitId_ShouldReturnDisplays()
|
||||
{
|
||||
@@ -402,6 +414,7 @@ public class DisplayServiceTest
|
||||
/// Verifies that UpdatePointOfCareList throws a <see cref="NotFoundException"/> when the display with the specified identifier does not exist.
|
||||
/// </summary>
|
||||
/// <exception cref="NotFoundException">Thrown when no display is found for the given id.</exception>
|
||||
/// <!-- aidoc:v1 sig=fe05ec6 body=46f08a3 -->
|
||||
[Test]
|
||||
public void UpdatePointOfCareList_ShouldThrow_WhenDisplayNotFound()
|
||||
{
|
||||
@@ -422,6 +435,8 @@ public class DisplayServiceTest
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the display whose configuration preset is being updated.</param>
|
||||
/// <param name="cfgId">The unique identifier of the configuration preset to associate with the display.</param>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=extra_param
|
||||
/// "The method has no parameters; 'id' and 'cfgId' are local variables, not method parameters, so the <param> tags document non-existent parameters." -->
|
||||
[Test]
|
||||
public void UpdateConfigPreset_ShouldThrow_WhenUpdateFails()
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ public class GroupedObservationServiceTest
|
||||
/// (configuration observation service, observation repository, logger, and cache service)
|
||||
/// and instantiating the <see cref="GroupedObservationService"/> under test with default API and cache settings.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=681afdf -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -46,6 +47,7 @@ public class GroupedObservationServiceTest
|
||||
/// verifying the distribution of observations across shifts for the current day, the previous day, and two days prior when the
|
||||
/// Result.Last aggregation is applied with a maximum count of 36.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=49572e1 body=ce7d966 -->
|
||||
[Test]
|
||||
public void Generate_Shift_Observations()
|
||||
{
|
||||
@@ -101,6 +103,7 @@ public class GroupedObservationServiceTest
|
||||
/// the current day, the previous day, and two days prior, ensuring that data is aggregated into the
|
||||
/// correct shift and day buckets.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d4b4f96 body=5a17087 -->
|
||||
[Test]
|
||||
public void Calculate_Shift_Observations()
|
||||
{
|
||||
@@ -248,6 +251,7 @@ public class GroupedObservationServiceTest
|
||||
/// so that the returned sequence contains a complete set of five consecutive hourly observations
|
||||
/// (covering the last five hours relative to the current time) for a group with hourly regularity and a maximum of five entries.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=667f3ff body=a77fd75 -->
|
||||
[Test]
|
||||
public async Task Calculate_Last_Filled_Observations_should_add_Minus_4_hour_to_complete_last_five_hours()
|
||||
{
|
||||
@@ -303,6 +307,7 @@ public class GroupedObservationServiceTest
|
||||
/// adding the <c>-1 hour</c> observation when it is not present in the provided list so that the returned
|
||||
/// collection always contains a complete five-hour window of last filled observations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f2c5b12 body=9dbcc21 -->
|
||||
[Test]
|
||||
public async Task Calculate_Last_Filled_Observations_should_add_Minus_1_hour_to_complete_last_five_hours()
|
||||
{
|
||||
@@ -356,6 +361,7 @@ public class GroupedObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the service correctly fills hourly observations from half-hour observation data, grouping timestamped values by hour and forwarding missing slots up to the configured maximum (5) per hour.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=381b258 body=ed397dd -->
|
||||
[Test]
|
||||
public void FillHoursObservations()
|
||||
{
|
||||
@@ -486,6 +492,7 @@ public class GroupedObservationServiceTest
|
||||
/// <param name="resultType">The result type that determines how the value is stored; aggregate types (HalfHour, Sum, Count, Min, Average, Max) are stored directly, while others are wrapped in a sub-document with time and stringified value.</param>
|
||||
/// <param name="all">Optional BsonArray of additional entries; when provided, it is appended to the result under the "all" key.</param>
|
||||
/// <returns>A BsonDocument containing the _id composite key, a time field, the result-type-specific payload, and optionally the "all" array.</returns>
|
||||
/// <!-- aidoc:v1 sig=e94c5ea body=f4284ca -->
|
||||
private static BsonDocument GenerateBsonDocument(int? year, int? month, int? day, int? hour, int? minute,
|
||||
string name, object value, Result resultType, BsonArray? all)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ internal class HistoricalConfigChangesServiceTest
|
||||
/// <summary>
|
||||
/// Initializes the mock repository, mock logger, and the <see cref="HistoricalConfigChangesService"/> instance under test prior to each unit test execution.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=f227270 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -44,6 +45,8 @@ internal class HistoricalConfigChangesServiceTest
|
||||
/// </summary>
|
||||
/// <param name="configType">The type of configuration whose last historical changes are being retrieved.</param>
|
||||
/// <returns>A task that represents the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=extra_param
|
||||
/// "The test method has no parameters, but the documentation includes a <param> tag for 'configType', which is actually a local variable, not a method parameter." -->
|
||||
[Test]
|
||||
public async Task FindLastConfigChanges_ReturnsLastConfigChange()
|
||||
{
|
||||
@@ -66,6 +69,7 @@ internal class HistoricalConfigChangesServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the service returns <c>null</c> when the underlying repository throws an exception while inserting a <see cref="HistoricalConfigChanges"/> entity.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=095d7c4 body=2da7496 -->
|
||||
[Test]
|
||||
public async Task InsertOne_WhenExceptionOccurs_ReturnsNull()
|
||||
{
|
||||
@@ -84,6 +88,7 @@ internal class HistoricalConfigChangesServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the service's <c>GetAll</c> method returns all historical configuration changes retrieved from the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=31f3dbb body=26fefb6 -->
|
||||
[Test]
|
||||
public async Task GetAll_ReturnsAllConfigChanges()
|
||||
{
|
||||
@@ -105,6 +110,7 @@ internal class HistoricalConfigChangesServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the service's <c>GetByType</c> method returns the expected number of historical configuration changes for the specified configuration type.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7b6a024 body=7e4b7fe -->
|
||||
[Test]
|
||||
public async Task GetByType_ReturnsCorrectAmountOfConfigs()
|
||||
{
|
||||
@@ -129,6 +135,7 @@ internal class HistoricalConfigChangesServiceTest
|
||||
/// Verifies that the service returns the expected number of historical configuration changes for a given user,
|
||||
/// confirming the repository result is correctly forwarded to the caller.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bbf6fad body=0c5f8a6 -->
|
||||
[Test]
|
||||
public async Task GetByUser_ReturnsCorrectConfigs()
|
||||
{
|
||||
@@ -151,6 +158,7 @@ internal class HistoricalConfigChangesServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the service returns null when an exception is thrown while updating a historical configuration change, ensuring graceful error handling.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f467039 body=fce2a66 -->
|
||||
[Test]
|
||||
public async Task UpdateHistoricalConfigChange_WhenExceptionOccurs_ReturnsNull()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ public class InMemoryLockProviderTest
|
||||
/// <summary>
|
||||
/// Initializes a fresh <see cref="InMemoryLockProvider"/> instance for the test fixture, ensuring each test starts with a clean, isolated provider state.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d8eb19f body=68e18d0 -->
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -28,6 +29,7 @@ public class InMemoryLockProviderTest
|
||||
/// Retrieves the private <c>_locks</c> dictionary from the associated <see cref="InMemoryLockProvider"/> instance using reflection, exposing the underlying locks for inspection or manipulation in tests.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="ConcurrentDictionary{TKey, TValue}"/> mapping lock keys to their <see cref="SemaphoreSlim"/> instances held by the provider.</returns>
|
||||
/// <!-- aidoc:v1 sig=4b79234 body=b646f1a -->
|
||||
private ConcurrentDictionary<string, SemaphoreSlim> GetLocks()
|
||||
{
|
||||
var field = typeof(InMemoryLockProvider)
|
||||
@@ -39,6 +41,7 @@ public class InMemoryLockProviderTest
|
||||
/// <summary>
|
||||
/// Verifies that AcquireAsync returns <c>true</c> and creates a corresponding entry in the locks dictionary when called with a valid key and time span.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a1004f7 body=bd67473 -->
|
||||
[Test]
|
||||
public async Task AcquireAsync_ReturnsTrue_AndCreatesEntryInLocksDictionary()
|
||||
{
|
||||
@@ -55,6 +58,7 @@ public class InMemoryLockProviderTest
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=095560b body=d74126f -->
|
||||
[Test]
|
||||
public async Task AcquireAsync_ReturnsFalse_WhenSemaphoreOccupiedAndTimeoutExpires()
|
||||
{
|
||||
@@ -77,6 +81,7 @@ public class InMemoryLockProviderTest
|
||||
/// allowing a subsequent <c>AcquireAsync</c> for the same key to succeed and the semaphore's
|
||||
/// <c>CurrentCount</c> to transition back to its released value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f6c51b5 body=9922475 -->
|
||||
[Test]
|
||||
public async Task ReleaseAsync_MakesSemaphoreAvailableForNextAcquire()
|
||||
{
|
||||
@@ -100,6 +105,7 @@ public class InMemoryLockProviderTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>ReleaseAsync</c> does not throw when invoked without a prior <c>AcquireAsync</c> for the given key, and remains safe to call multiple times after a single successful acquire.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6c5ff9c body=919f96b -->
|
||||
[Test]
|
||||
public async Task ReleaseAsync_DoesNotThrow_WhenCalledWithoutPriorAcquire()
|
||||
{
|
||||
@@ -115,6 +121,7 @@ public class InMemoryLockProviderTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>AcquireAsync</c> 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.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d53d431 body=e5e915a -->
|
||||
[Test]
|
||||
public async Task AcquireAsync_IsThreadSafe_OnlyOneHolderAtATime_SingleSemaphorePerKey()
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ public class LightBeaconServiceTest
|
||||
/// and instantiating the <see cref="LightBeaconService"/> under test with those mocks.
|
||||
/// This setup runs before each test to ensure a clean, isolated test environment.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=18cf5be -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -66,6 +67,7 @@ public class LightBeaconServiceTest
|
||||
/// <summary>
|
||||
/// Integration test that verifies the light beacon service returns <see cref="LightBeaconColor.Off"/> for a given point of care when the patient has no associated beacon color.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fa06230 body=9e0a869 -->
|
||||
[Ignore("Integration test")]
|
||||
[Test]
|
||||
public async Task GetBeaconColor()
|
||||
|
||||
@@ -25,6 +25,7 @@ public class MasterListServiceTest
|
||||
/// for use in unit tests. Configures the HTTP context with a test user principal, registers the master list repository
|
||||
/// in the service provider, and supplies default API settings.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=b470369 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -95,6 +96,7 @@ public class MasterListServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>DeleteMasterListById</c> invokes the repository's <c>Delete</c> method once with the provided identifier when the master list is found.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ea99ebf body=df3195e -->
|
||||
[Test]
|
||||
public async Task DeleteMasterListById_ShouldCallRepositoryDelete_WhenMasterListFound()
|
||||
{
|
||||
@@ -132,6 +134,7 @@ public class MasterListServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the service returns the master list when it is found by the specified id.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ccec55b body=8cfdb62 -->
|
||||
[Test]
|
||||
public async Task GetMasterListById_ShouldReturnMasterList_WhenFound()
|
||||
{
|
||||
@@ -151,6 +154,7 @@ public class MasterListServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>GetMasterListByName</c> returns the matching <see cref="MasterList"/> when a master list with the specified name is found in the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e75f465 body=49f48d4 -->
|
||||
[Test]
|
||||
public async Task GetMasterListByName_ShouldReturnMasterList_WhenFound()
|
||||
{
|
||||
@@ -170,6 +174,7 @@ public class MasterListServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the InsertMasterList service method returns the same <see cref="MasterList"/> instance that was inserted, ensuring the service correctly retrieves the inserted entity by its identifier after persistence.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d6a0851 body=1cc5b44 -->
|
||||
[Test]
|
||||
public async Task InsertMasterList_ShouldReturnInsertedMasterList()
|
||||
{
|
||||
@@ -191,6 +196,7 @@ public class MasterListServiceTest
|
||||
/// Verifies that UpdateMasterList returns the updated master list when the repository successfully completes the update and finds the entity by id.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=870cac2 body=e6d0735 -->
|
||||
[Test]
|
||||
public async Task UpdateMasterList_ShouldReturnUpdatedMasterList()
|
||||
{
|
||||
|
||||
@@ -68,6 +68,8 @@ public class MedicineServiceTest
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException">Thrown when the local <see cref="List{PatientTreatment}"/> collection is null.</exception>
|
||||
/// <!-- aidoc:v1 sig=6587029 body=89ace4d -->
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=extra_exception
|
||||
/// "ArgumentNullException is unreachable: patientTreatment is initialized to an empty list (List<PatientTreatment> patientTreatment = []) immediately before the null check, so the throw can never execute in practice." -->
|
||||
[Test]
|
||||
public async Task GetMedicinesOfTreatments_Null_Medicine_Return_0()
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ public class NoCacheServiceTest
|
||||
/// Initializes a fresh <see cref="NoCacheService"/> instance and assigns it to <c>_noCacheService</c>
|
||||
/// to provide a clean, dependency-free test fixture prior to executing each test.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d8eb19f body=f419747 -->
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -87,6 +88,7 @@ public class NoCacheServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the no-cache service implementation never persists data to any backend when <c>GetOrSetObjectAsync</c> is invoked, and confirms that a subsequent <c>DeleteObjectAsync</c> on the same key does not throw.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9b41a17 body=279c122 -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_DoesNotStoreData_InAnyBackend()
|
||||
{
|
||||
@@ -114,6 +116,7 @@ public class NoCacheServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the no-cache service's <c>DeleteByPatternAsync</c> returns 0 and does not throw when invoked with arbitrary patterns, confirming the no-op delete behavior for any key pattern.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d8ac365 body=97d47fa -->
|
||||
[Test]
|
||||
public async Task DeleteByPatternAsync_ReturnsZero_DoesNotThrow()
|
||||
{
|
||||
@@ -134,6 +137,7 @@ public class NoCacheServiceTest
|
||||
/// Verifies that calling CleanCache on the no-cache service is a safe no-op that does not throw,
|
||||
/// and that subsequent calls to GetValue consistently return <c>null</c> for any key.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=732eb50 body=c99cdf2 -->
|
||||
[Test]
|
||||
public void CleanCache_IsNoOp_DoesNotThrow()
|
||||
{
|
||||
@@ -149,6 +153,7 @@ public class NoCacheServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that calling <c>SetValue</c> on the no-cache service is a no-op and does not throw any exception.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=93ab163 body=4352e8e -->
|
||||
[Test]
|
||||
public void SetValue_IsNoOp_DoesNotThrow()
|
||||
{
|
||||
@@ -163,6 +168,7 @@ public class NoCacheServiceTest
|
||||
/// Verifies that the no-cache service's GetValue method returns null for any key,
|
||||
/// confirming that the no-op implementation does not return or simulate cached values.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=11d9010 body=0d07264 -->
|
||||
[Test]
|
||||
public void GetValue_IsNoOp_ReturnsNull()
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ public class ObservationServiceTest
|
||||
/// and pre-configuring common lookup behavior for the default "UCI5C" unit (including <c>FindByName</c>
|
||||
/// and <c>FindById</c>) along with the <c>ICalculatedObservationsService.Map</c> passthrough.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=fc042ee -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -668,6 +669,7 @@ public class ObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an isolation observation is processed through SaveRequest, the configuration observation and units mapping services are invoked, and the resulting mapped observation is inserted into the observation repository with the expected value, patient identifier, name, time, message time, and coding system.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7f3122b body=1cb0aef -->
|
||||
[Test]
|
||||
public async Task ProcessIsolationObservation_Return_IsolationObs()
|
||||
{
|
||||
@@ -755,6 +757,7 @@ public class ObservationServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that processing a position observation through the observation service persists a new <see cref="PatientObservation"/> with the expected values (Value, PatientId, Name, Time, MessageTime, and CodingSystem) when a valid API request is provided.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e65e6d9 body=fde3bdd -->
|
||||
[Test]
|
||||
public async Task ProcessPositionObservation_Return_PositionObs()
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ internal class PatientServiceTest
|
||||
/// dependencies and pre-configuring common lookup scenarios for units and points of care, including virtual
|
||||
/// point of care states (Pushed, Moved, Deleted, Cancelled, Recovered, Unknown) used across test cases.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=ff2a3d0 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -320,6 +321,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the patient service correctly retrieves a patient from the database by matching the patient number supplied in the API request, returning a patient populated with the expected unit, point of care, and patient number values.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ef29ee9 body=8931a6e -->
|
||||
[Test]
|
||||
public async Task Find_Patient_By_APIRequest_Get_Patient_By_PatientNumber()
|
||||
{
|
||||
@@ -371,6 +373,7 @@ internal class PatientServiceTest
|
||||
/// Verifies that <see cref="PatientService.FindPatientByApiRequest"/> creates a new patient record
|
||||
/// when the requested patient does not exist and the <c>CreatePatientWithOru</c> option is set to <c>true</c>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=06e0a26 body=2d5f690 -->
|
||||
[Test]
|
||||
public async Task Find_Patient_By_APIRequest_Not_Exists_CreatePatientWithORU_True_Created_Patient()
|
||||
{
|
||||
@@ -445,6 +448,7 @@ internal class PatientServiceTest
|
||||
/// while the target location is already occupied by another patient, and the <c>CreatePatientWithOru</c>
|
||||
/// option is enabled, the service creates a new patient in a temporal bed instead of reusing the occupied location.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a57196b body=beeb5bf -->
|
||||
[Test]
|
||||
public async Task
|
||||
Find_Patient_By_APIRequest_Not_Exists_And_Location_Ocuped_CreatePatientWithORU_True_Created_In_Temporal_Bed()
|
||||
@@ -530,6 +534,7 @@ internal class PatientServiceTest
|
||||
/// the <see cref="Patient"/> is not created in the temporal bed because <c>CreatePatientWithOru</c> is set to <c>false</c>.
|
||||
/// Ensures that <c>FindPatientByApiRequest</c> returns <c>null</c> and that the repository's <c>InsertOneAsync</c> is never invoked.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e6921b4 body=35ecb59 -->
|
||||
[Test]
|
||||
public async Task Find_Patient_By_APIRequest_Not_Exists_CreatePatientWithORU_False_Not_Created_In_Temporal_Bed()
|
||||
{
|
||||
@@ -596,6 +601,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when a patient is found by API request and the patient already exists in a different location in the database, the patient's location is not changed by the lookup operation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d023325 body=4efbf14 -->
|
||||
[Test]
|
||||
public async Task Find_Patient_By_APIRequest_Exists_In_Different_Location_NOT_Changes_Patient_Location()
|
||||
{
|
||||
@@ -648,6 +654,7 @@ internal class PatientServiceTest
|
||||
/// Verifies that an ADT_A01 request correctly inserts a new patient into the specified unit and bed location
|
||||
/// by ensuring the patient repository is updated with the matching unit, bed, and patient number.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=54b6ee5 body=52efd9d -->
|
||||
[Test]
|
||||
public async Task ADT_A01_New_Patient_Empty_Bed_Insert_In_Location()
|
||||
{
|
||||
@@ -679,6 +686,7 @@ internal class PatientServiceTest
|
||||
/// Verifies that when an ADT_A01 request for a new patient is processed with an unknown location
|
||||
/// (i.e., the location mapping resolves to null), the patient is not inserted into the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a7816da body=592765f -->
|
||||
[Test]
|
||||
public async Task ADT_A01_New_Patient_Unknown_Location_Insert_Nothing()
|
||||
{
|
||||
@@ -708,6 +716,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A01 admission request is received for a new patient targeting a bed that is already in use by an existing patient, the existing patient is moved to the temporal (pushed) bed while the new patient is admitted to the original bed.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f6f4884 body=f0a1e9f -->
|
||||
[Test]
|
||||
public async Task ADT_A01_New_Patient_Bed_In_Use_Moves_Existing_Patient_To_Temporal_Bed()
|
||||
{
|
||||
@@ -839,6 +848,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A01 (Admit) message is received for a patient whose bed is already in use and whose patient number matches an existing patient, the patient's demographic data is updated while preserving the bed assignment and existing identifiers.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=207b25e body=bc34164 -->
|
||||
[Test]
|
||||
public async Task ADT_A01_New_Patient_Bed_In_Use_With_Same_Patient_Number_Updates_Demographic_Data()
|
||||
{
|
||||
@@ -910,6 +920,10 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that processing an ADT_A05 message for a new patient in a new bed (PatientLocation) results in the patient being updated with the correct unit, point of care, and patient number, and that the point-of-care mapping service is invoked to create the location.
|
||||
/// </summary>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "The documentation says 'ADT_A05 message' but the code sets apiRequest.Type = 'ADT_A01', so the test processes an ADT_A01 message, not ADT_A05." -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "The documentation claims the test verifies 'that the point-of-care mapping service is invoked to create the location', but there is no Verify call for _poCMappingServiceMock; only a Setup stub is configured, and only the patient repository's Update is verified." -->
|
||||
[Test]
|
||||
public async Task ADT_A05_New_Patient_New_Bed_Creates_Location()
|
||||
{
|
||||
@@ -944,6 +958,7 @@ internal class PatientServiceTest
|
||||
/// the existing patient in that bed is moved to a temporal PointOfCare, while the new patient
|
||||
/// is assigned to the original PointOfCare location.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fbe1c2f body=f3b3776 -->
|
||||
[Test]
|
||||
public async Task ADT_A05_New_Patient_Bed_In_Use_Moves_Existing_Patient_To_Temporal_Bed()
|
||||
{
|
||||
@@ -1001,6 +1016,7 @@ internal class PatientServiceTest
|
||||
/// Verifies that when an ADT_A03 (End Visit) message is processed for a patient that does not exist,
|
||||
/// the patient repository's Update operation is never invoked, ensuring the system takes no action.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=569f0a9 body=4815209 -->
|
||||
[Test]
|
||||
public async Task ADT_A03_END_VISIT_PATIENT_NOT_EXISTS_DO_NOTHING()
|
||||
{
|
||||
@@ -1032,6 +1048,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A03 (End Visit) request is processed for a patient that already exists in the database, the patient record is updated with the deleted Point of Care, the unit identifier is preserved, and the next admission check is triggered for the original Point of Care.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=df708cd body=1a6d3f8 -->
|
||||
[Test]
|
||||
public async Task ADT_A03_END_VISIT_PATIENT_EXISTS()
|
||||
{
|
||||
@@ -1177,6 +1194,7 @@ internal class PatientServiceTest
|
||||
/// service to resolve the destination location, ensuring the save operation results in a single
|
||||
/// insert for the new patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6bb7428 body=852c38d -->
|
||||
[Test]
|
||||
public async Task ADT_A02_TRANSFER_PATIENT_FROM_NOT_EXISTS_BED_TO_BED_SHOULD_CREATE_PATIENT()
|
||||
{
|
||||
@@ -1223,6 +1241,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Tests the ADT_A02 transfer scenario where a patient is transferred from their current bed to a bed that is already occupied by another patient, verifying that the existing patient is moved to a new location, the transferring patient occupies the destination bed, and related discharge and next-admission checks are invoked.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=445abff body=64dbe17 -->
|
||||
[Test]
|
||||
public async Task ADT_A02_TRANSFER_PATIENT_FROM_BED_TO_IN_USE_BED()
|
||||
{
|
||||
@@ -1298,6 +1317,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A02 transfer message is processed for a patient moving from a location with no existing patient to a bed that is already occupied, the previously assigned patient is moved to a temporal bed and the new patient is inserted into the vacated bed.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4d1f5ba body=60f333b -->
|
||||
[Test]
|
||||
public async Task
|
||||
ADT_A02_TRANSFER_PATIENT_FROM_NOT_EXISTS_TO_NOT_EMPTY_BED_SHOULD_CHANGE_LAST_PATIENT_TO_TEMPORTAL_BED()
|
||||
@@ -1354,6 +1374,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that processing an ADT_A02 transfer request for a patient whose patient number already exists in the destination bed updates the existing patient's demographic data instead of creating a new patient record.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=33bdcd5 body=a2f7027 -->
|
||||
[Test]
|
||||
public async Task
|
||||
ADT_A02_TRANSFER_PATIENT_FROM_NOT_EXISTS_BED_TO_NOT_EMPTY_BED_WITH_SAME_PATIENT_NUMBER_SHOULD_UPTADE_DEMOGRAPHIC_DATA()
|
||||
@@ -1411,6 +1432,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that processing an ADT_A04 message for a new patient successfully creates and persists a patient record with the expected unit, point of care, and patient number.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=5feb5e2 body=5c4855e -->
|
||||
[Test]
|
||||
public async Task ADT_A04_New_Patient_Creates_Patient()
|
||||
{
|
||||
@@ -1443,6 +1465,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when processing an ADT_A04 request for a new patient with a location whose POC mapping returns null, the patient is not persisted to the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ff36bdc body=a4fb145 -->
|
||||
[Test]
|
||||
public async Task ADT_A04_New_Patient_Not_Location_Creates_Patient()
|
||||
{
|
||||
@@ -1473,6 +1496,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A08 request is received for a non-existent patient and the <c>CreatePatientWithAdtA08</c> option is enabled, the <see cref="PatientService"/> correctly creates the patient by calling the patient repository's <c>Update</c> method with the expected <c>UnitId</c>, <c>PointOfCareId</c>, and <c>PatientNumber</c> values.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0011533 body=5222130 -->
|
||||
[Test]
|
||||
public async Task ADT_A08_No_exist_CreatePatientWithADT_A08_True_Patient_Creates_Patient()
|
||||
{
|
||||
@@ -1541,6 +1565,7 @@ internal class PatientServiceTest
|
||||
/// Verifies that when an ADT_A08 message is processed for a patient that does not exist and the
|
||||
/// <c>CreatePatientWithAdtA08</c> option is disabled, the patient is not inserted into the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4787677 body=e1846b5 -->
|
||||
[Test]
|
||||
public async Task ADT_A08_No_exist_Patient_Not_Creates_Patient()
|
||||
{
|
||||
@@ -1608,6 +1633,7 @@ internal class PatientServiceTest
|
||||
/// and patient creation on ADT_A08 is disabled, the patient is updated rather than created.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=f8df471 body=e1407e8 -->
|
||||
[Test]
|
||||
public async Task ADT_A08_Exist_Patient_Update_Patient()
|
||||
{
|
||||
@@ -1681,6 +1707,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that processing an ADT_A11 (cancel admit/visit notification) message for an existing patient updates the patient's location to the cancelled point of care, leaving unit, patient number, and identity fields unchanged.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d05b038 body=5bf7535 -->
|
||||
[Test]
|
||||
public async Task ADT_A11_Exist_Patient_CANCELLED_Patient()
|
||||
{
|
||||
@@ -1757,6 +1784,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A11 (cancel admit/visit notification) request is processed for a non-existent patient, the patient repository's <c>UpdateOneAsync</c> method is never invoked, since there is no existing patient record to update.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=cc97dcc body=7db5096 -->
|
||||
[Test]
|
||||
public async Task ADT_A11_No_Exist_Patient_Not_CANCELLED_Patient()
|
||||
{
|
||||
@@ -1819,6 +1847,7 @@ internal class PatientServiceTest
|
||||
/// Verifies that processing an ADT_A12 transfer message for a non-existing patient to an empty bed
|
||||
/// results in the patient being created and assigned to the target bed via the point-of-care mapping.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=eb39efa body=6eec376 -->
|
||||
[Test]
|
||||
public async Task ADT_A12_TRANSFER_PATIENT_NOT_EXISTS_TO_EMPTY_BED_SHOULD_CREATE_BED()
|
||||
{
|
||||
@@ -1852,6 +1881,7 @@ internal class PatientServiceTest
|
||||
/// creates the bed (represented by a new point of care) and persists the patient's transfer to that
|
||||
/// new location under the configured unit.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7d75980 body=1a080c9 -->
|
||||
[Test]
|
||||
public async Task ADT_A12_TRANSFER_PATIENT_FROM_BED_TO_NOT_EXISTS_BED_SHOULD_CREATE_BED()
|
||||
{
|
||||
@@ -1893,6 +1923,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A12 transfer request is processed, the new patient occupying the target bed has their data updated while the displaced patient is relocated to a different point of care, and that the legacy <c>Update</c> method is not invoked.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=788fe08 body=89347c8 -->
|
||||
[Test]
|
||||
public async Task ADT_A12_TRANSFER_PATIENT_FROM_BED_TO_IN_USE_BED()
|
||||
{
|
||||
@@ -1967,6 +1998,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A12 transfer is processed for a patient moving to a bed that is already occupied, the existing patient in that bed is moved to a temporary bed (different Point of Care), and the transferred patient is inserted into the target bed.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b3f2ed3 body=a43a5e5 -->
|
||||
[Test]
|
||||
public async Task
|
||||
ADT_A12_TRANSFER_PATIENT_NOT_EXISTS_TO_NOT_EMPTY_BED_SHOULD_CHANGE_LAST_PATIENT_TO_TEMPORTAL_BED()
|
||||
@@ -2021,6 +2053,8 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A13 transfer request is processed for a patient moving to a bed that is already occupied, the previously assigned patient in that bed is moved to a temporal bed while the transferring patient is persisted in the requested location.
|
||||
/// </summary>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "Summary claims the previously assigned patient is moved to a temporal bed, but the test only verifies that the transferring patient is updated at the target location; no assertion or mock verifies the prior occupant's relocation to a temporal bed." -->
|
||||
[Test]
|
||||
public async Task
|
||||
ADT_A13_TRANSFER_PATIENT_NOT_EXISTS_TO_NOT_EMPTY_BED_SHOULD_CHANGE_LAST_PATIENT_TO_TEMPORTAL_BED()
|
||||
@@ -2063,6 +2097,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that processing an ADT_A13 transfer request for a patient assigned to a deleted point of care moves the patient to the recovered (temporal) bed location.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d80f16e body=ea343c5 -->
|
||||
[Test]
|
||||
public async Task ADT_A13_TRANSFER_PATIENT_NOT_EXISTS_TO_EMPTY_BED_SHOULD_CHANGE_LAST_PATIENT_TO_TEMPORTAL_BED()
|
||||
{
|
||||
@@ -2112,6 +2147,7 @@ internal class PatientServiceTest
|
||||
/// Verifies that processing an ADT_A31 (Update Patient) HL7 request correctly updates the existing patient's demographic
|
||||
/// information (last name and birth date) while preserving the assigned unit and point of care identifiers.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d30f8e5 body=1a5e43f -->
|
||||
[Test]
|
||||
public async Task ADT_A31_Upadate_Patient()
|
||||
{
|
||||
@@ -2159,6 +2195,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A31 update request is processed for a patient that does not exist, the patient is not updated. Ensures the repository's Update method is never invoked in the not-found scenario.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c01058d body=e9b1919 -->
|
||||
[Test]
|
||||
public async Task ADT_A31_Upadate_Patient_Not_Found_Not_Update()
|
||||
{
|
||||
@@ -2191,6 +2228,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ADT_A39 merge patient request is processed, the old patient record is deleted after the new patient is resolved through the point-of-care mapping and patient repository lookups.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b442eb3 body=32ea4bf -->
|
||||
[Test]
|
||||
public async Task ADT_A39_Merge_Patient()
|
||||
{
|
||||
@@ -2246,6 +2284,7 @@ internal class PatientServiceTest
|
||||
/// Verifies that when an <c>ADT_A39</c> request is processed and the patient is not an old patient (i.e., not a merge case),
|
||||
/// the <see cref="PatientService.SaveRequest"/> does not delete the existing patient from the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0442333 body=8b45017 -->
|
||||
[Test]
|
||||
public async Task ADT_A39_Not_OldPatient_Not_Merge_Patient()
|
||||
{
|
||||
@@ -2285,6 +2324,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that processing an ADT_A39 (merge patient) request does not result in the deletion of the old patient record, even when the old patient is located by number.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=85734e7 body=fdeab08 -->
|
||||
[Test]
|
||||
public async Task ADT_A39_Not_Patient_Not_Merge_Patient()
|
||||
{
|
||||
@@ -2328,6 +2368,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the patient service correctly handles an ADT_A44 patient merge/update request by locating the existing patient via the old patient number and updating it in the repository with the new patient information.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=cd35acc body=16982fd -->
|
||||
[Test]
|
||||
public async Task ADT_A44_Upadate_Patient()
|
||||
{
|
||||
@@ -2369,6 +2410,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that processing an ADT_A44 request for a patient that is not an old patient does not trigger a patient update.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=84f3f56 body=0fdeb6d -->
|
||||
[Test]
|
||||
public async Task ADT_A44_Not_OldPatient_Not__Upadate_Patient()
|
||||
{
|
||||
@@ -2402,6 +2444,7 @@ internal class PatientServiceTest
|
||||
/// through the patient service by calling <c>SaveRequest</c> with an <c>ApiRequest</c> of type "ICCA" containing four
|
||||
/// patients located in different points of care, and confirms each one is persisted exactly once via the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=db9be10 body=6c05a4c -->
|
||||
[Test]
|
||||
public async Task ICCA_Process_No_Patient_BD_Insert_ICCA_Patients()
|
||||
{
|
||||
@@ -2470,6 +2513,7 @@ internal class PatientServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that when an ICCA patient request is processed and a patient already exists in the database at the same point of care but with a different patient number, the existing patient is updated to the moved point of care and the new ICCA patient is inserted.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=844f9ba body=c4fd746 -->
|
||||
[Test]
|
||||
public async Task ICCA_Process_Patient_BD_Insert_ICCA_Patient_Pushed_Actual_Patient()
|
||||
{
|
||||
@@ -2527,6 +2571,7 @@ internal class PatientServiceTest
|
||||
/// and the ICCA patients collection is empty, the existing patient is updated with the UNKNOWN
|
||||
/// PointOfCareId and no new patient is inserted into the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a53cb38 body=a8ccf49 -->
|
||||
[Test]
|
||||
public async Task ICCA_Process_Patient_BD_No_Insert_ICCA_Patient_UNKNOWN_Actual_Patient()
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ public class PointOfCareServiceTests
|
||||
/// Configures repository, service, cache, admission, unit, and HTTP context mocks, including a simulated authenticated user
|
||||
/// and cache behavior that invokes the supplied factory directly to return the produced <see cref="PointOfCare"/> instance.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d8eb19f body=249b5e3 -->
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -84,6 +85,7 @@ public class PointOfCareServiceTests
|
||||
/// when invoked with a valid <see cref="ObjectId"/> whose associated admission is <c>null</c>, ensuring
|
||||
/// the underlying repository's delete operation is invoked.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fbe967c body=3dbace5 -->
|
||||
[Test]
|
||||
public async Task Delete_ValidObjectId_DeletesPointOfCare()
|
||||
{
|
||||
@@ -105,6 +107,7 @@ public class PointOfCareServiceTests
|
||||
/// <see cref="PointOfCare"/> instance by delegating the operation to the underlying repository.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=ce1f679 body=430d93e -->
|
||||
[Test]
|
||||
public async Task Update_ValidPointOfCare_UpdatesPointOfCare()
|
||||
{
|
||||
@@ -122,6 +125,7 @@ public class PointOfCareServiceTests
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="PointOfCareService.GetAll"/> returns the complete list of point of care records provided by the repository when invoked with no arguments.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1ff5b52 body=e781807 -->
|
||||
[Test]
|
||||
public async Task GetAll_NoArguments_ReturnsListOfPointOfCare()
|
||||
{
|
||||
@@ -139,6 +143,7 @@ public class PointOfCareServiceTests
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="PointOfCareService.UpdateConfiguration"/> throws a <see cref="ConflictException"/> when invoked with a valid id and configuration, ensuring the service surfaces conflict conditions during the update operation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1b073df body=7d7853b -->
|
||||
[Test]
|
||||
public void UpdateConfiguration_ValidIdAndConfiguration_InvokesRepositoryUpdateConfiguration()
|
||||
{
|
||||
@@ -157,6 +162,7 @@ public class PointOfCareServiceTests
|
||||
/// <summary>
|
||||
/// Verifies that <c>FindById</c> returns the expected <see cref="PointOfCare"/> when a valid identifier is provided.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8808d2e body=a1b38fe -->
|
||||
[Test]
|
||||
public async Task FindById_ValidId_ReturnsPointOfCare()
|
||||
{
|
||||
@@ -196,6 +202,7 @@ public class PointOfCareServiceTests
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="PointOfCareService.FindByUnitAndStatus"/> returns the expected list of point-of-care records when invoked with a valid unit identifier and status.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dda43eb body=2469c00 -->
|
||||
[Test]
|
||||
public async Task FindByUnitAndStatus_ValidUnitIdAndStatus_ReturnsListOfPointOfCare()
|
||||
{
|
||||
@@ -300,6 +307,7 @@ public class PointOfCareServiceTests
|
||||
/// <summary>
|
||||
/// Tests that the service's FindByRoom method, when called with a valid room, returns the collection provided by the repository and invokes the repository's FindByRoom exactly once.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=89ccc77 body=dd6415f -->
|
||||
[Test]
|
||||
public async Task FindByRoom_ValidRoom_CallsRepositoryFindByRoom()
|
||||
{
|
||||
@@ -319,6 +327,7 @@ public class PointOfCareServiceTests
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="PointOfCareService.FindByBed"/> method correctly delegates to the repository's FindByBed method when a valid bed identifier is provided, returning the expected collection of point of care records.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=28d655e body=0851f2e -->
|
||||
[Test]
|
||||
public async Task FindByBed_ValidBed_CallsRepositoryFindByBed()
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ public class PublisherServiceTest
|
||||
/// <summary>
|
||||
/// Initializes the test environment for <see cref="PublisherService"/> by configuring RabbitMQ settings, creating a mocked logger, and instantiating the service under test.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=b5bc3e1 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -50,6 +51,7 @@ public class PublisherServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the publisher service's SendMessage method returns a non-null result when sending a message to the observations queue.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ec11b0e body=15bae5a -->
|
||||
[Test]
|
||||
public void SendMessage_Return_true()
|
||||
{
|
||||
@@ -63,6 +65,7 @@ public class PublisherServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>SendMessageError</c> returns a non-null result when publishing a new <see cref="Message{Error}"/> to the observations queue.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=565955d body=04f3cbb -->
|
||||
[Test]
|
||||
public void SendMessage_Error_Return_true()
|
||||
{
|
||||
|
||||
@@ -50,6 +50,7 @@ public class PumpServiceTest
|
||||
/// <summary>
|
||||
/// Initializes the unit test fixture by creating mock repositories, services, and a mocked <see cref="HttpContext"/> with a test claims principal, then instantiates the <see cref="PumpService"/> under test using the configured API settings (5-second pump expiration, zero pump messages disabled). Pass-through mappings are configured for <see cref="ICalculatedObservationsService"/>, <see cref="IConfigPumpsService"/>, and <see cref="IConfigUnitsService"/> so that supplied pump observations are returned unchanged.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=872fc6b -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -115,6 +116,7 @@ public class PumpServiceTest
|
||||
/// Verifies that <see cref="ApiRequest"/> processing does not insert any <see cref="PumpObservation"/> records
|
||||
/// when the request is saved without associated observations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=42b8c0e body=dd944a2 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Returns_When_No_Observations()
|
||||
{
|
||||
@@ -126,6 +128,7 @@ public class PumpServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>SaveRequest</c> does not insert a <see cref="PumpObservation"/> when the <see cref="ApiRequest.Type"/> is an unrecognized value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f664650 body=4ef2165 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_UnknownType_DoesNotInsert()
|
||||
{
|
||||
@@ -143,6 +146,7 @@ public class PumpServiceTest
|
||||
/// Verifies that SaveRequest converts a single <c>PumpObservation</c> on an incoming
|
||||
/// <c>ApiRequest</c> into a list with one entry on the request after processing.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ffee994 body=257a0a7 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Converts_SingleObservation_ToList()
|
||||
{
|
||||
@@ -164,6 +168,7 @@ public class PumpServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that Service.SaveRequest sets the <c>Expires</c> property of the <see cref="PumpObservation"/> before persisting it via the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f82c67c body=9a75bd3 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_SetsExpires_BeforeInsert()
|
||||
{
|
||||
@@ -196,6 +201,7 @@ public class PumpServiceTest
|
||||
/// and does not create a <see cref="PumpObservation"/>, ensuring alarm-phase events are
|
||||
/// routed to the alarm event store rather than the observation store.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=5d43d51 body=5d854f0 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_ORU_R40_CreatesAlarmEvent()
|
||||
{
|
||||
@@ -221,6 +227,7 @@ public class PumpServiceTest
|
||||
/// Verifies that processing a pump observation with <c>EventPhase.End</c> removes the corresponding alarm state
|
||||
/// by calling <c>RemoveAsync</c> on the alarm state repository with the matching device, alarm type, and MDC code.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bc95230 body=ed3bff2 -->
|
||||
[Test]
|
||||
public async Task ProcessAlarm_End_RemovesAlarmState()
|
||||
{
|
||||
@@ -249,6 +256,7 @@ public class PumpServiceTest
|
||||
/// Verifies that <c>SaveRequest</c> creates and upserts a new <see cref="PumpState"/>
|
||||
/// for the device when no existing pump state is found in the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a8ef24c body=b070da6 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_CreatesPumpState_IfNotExists()
|
||||
{
|
||||
@@ -273,6 +281,7 @@ public class PumpServiceTest
|
||||
/// Verifies that SaveRequest does not broadcast a message via the client when there are no active subscribers.
|
||||
/// </summary>
|
||||
/// <returns>A task that completes when the assertion has been executed.</returns>
|
||||
/// <!-- aidoc:v1 sig=7b9c477 body=f817038 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_NoSubscribers_NoBroadcast()
|
||||
{
|
||||
@@ -372,6 +381,7 @@ public class PumpServiceTest
|
||||
/// <c>DeleteOlderThanDaysAsync</c> method with the configured retention value when the
|
||||
/// retention policy returned for the pump observation is <c>DeleteOlderDays</c>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d2dfd4d body=d351b0f -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Retention_DeleteOlderDays_CallsRepo()
|
||||
{
|
||||
@@ -399,6 +409,7 @@ public class PumpServiceTest
|
||||
/// Verifies that <c>GetPaginatedPump</c> returns the correct paginated results when filtering by patient identifier.
|
||||
/// Ensures the first page contains the most recent observation within the configured time tolerance.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b7d70a0 body=0ac38ce -->
|
||||
[Test]
|
||||
public async Task GetPaginatedPump_ByPatient_Works()
|
||||
{
|
||||
@@ -434,6 +445,7 @@ public class PumpServiceTest
|
||||
/// Verifies that <c>ArchiveByPatientId</c> inserts the patient's pump observations into the archive
|
||||
/// repository and then deletes them, along with their related alarm events and alarm states.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7f95b21 body=fcc366d -->
|
||||
[Test]
|
||||
public async Task ArchiveByPatientId_InsertsArchive_ThenDeletes()
|
||||
{
|
||||
@@ -459,6 +471,7 @@ public class PumpServiceTest
|
||||
/// Verifies that <c>UpdateManyObjectId</c> correctly updates the patient identifier across observations, alarms, and alarm state repositories.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=b51830b body=7584081 -->
|
||||
[Test]
|
||||
public async Task UpdateManyObjectId_UpdatesObs_Alarms_States()
|
||||
{
|
||||
@@ -483,6 +496,7 @@ public class PumpServiceTest
|
||||
/// Verifies that <c>FindLastPumpObservations</c> returns pump observations ordered with the most recent first,
|
||||
/// returning only the specified number of latest entries when the repository provides multiple observations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7cbd1eb body=331060b -->
|
||||
[Test]
|
||||
public async Task FindLastPumpObservations_ReturnsOrdered()
|
||||
{
|
||||
@@ -508,6 +522,7 @@ public class PumpServiceTest
|
||||
/// Verifies that InsertPumpObservation persists the observation and upserts the corresponding
|
||||
/// pump state when no existing state is found for the device and there are no active subscribers.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=98c89e1 body=3e74c5d -->
|
||||
[Test]
|
||||
public async Task InsertPumpObservation_Inserts_AndBroadcasts()
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ public class RecordingAlertServiceTest
|
||||
/// <summary>
|
||||
/// Initializes the mocked dependencies and test infrastructure required by the <see cref="RecordingAlertService"/> unit tests, including service and repository mocks, a fake HTTP context with a "TestUser" claim, and the system-under-test instance.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=ef6880f -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -88,6 +89,7 @@ public class RecordingAlertServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="RecordingAlertService.SaveRequest"/> does not persist a <see cref="PatientRecordingAlert"/> when the provided <see cref="ApiRequest"/> is neither a recording alert nor an ORU R01 message.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=25109a2 body=153205d -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Not_RecordingAlert_Not_ORU_R01_Return_not_insert()
|
||||
{
|
||||
@@ -101,6 +103,7 @@ public class RecordingAlertServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="RecordingAlertService.SaveRequest"/> does not insert a <see cref="PatientRecordingAlert"/> when both the patient number and point of care are null in the <see cref="ApiRequest"/>, even when the message type is "ORU_R11".
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=84b4d02 body=8ae3d26 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_patientNumber_and_pointOfCare_null_Return_not_insert()
|
||||
{
|
||||
@@ -118,6 +121,7 @@ public class RecordingAlertServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the SaveRequest method does not insert a patient recording alert when the specified patient cannot be found.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=67b2be6 body=931ed14 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Not_Find_Patient_Return_not_insert()
|
||||
{
|
||||
@@ -146,6 +150,7 @@ public class RecordingAlertServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that SaveRequest inserts a new <see cref="PatientRecordingAlert"/> into the repository when the configuration observation service returns no retention actions for the given recording alert.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9d79768 body=ecbd046 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Alert_Return_insert()
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ public class RecordingServiceTest
|
||||
/// dependencies (logger, HTTP client factory, publisher, authentication, client message, subscribers, and patient services),
|
||||
/// and configuring the publisher mock to successfully send both regular messages and errors.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=858be2c -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -108,6 +109,7 @@ public class RecordingServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="RecordingService.GetRecordings"/> returns an empty collection of <see cref="RecordingData"/> when the HTTP response indicates an unauthorized (401) status, ensuring the service correctly handles failed authentication scenarios by yielding no recordings rather than throwing or returning null.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2d4a973 body=2d5face -->
|
||||
[Test]
|
||||
public async Task GetRecordings_Return_Empty()
|
||||
{
|
||||
@@ -138,6 +140,7 @@ public class RecordingServiceTest
|
||||
/// when the HTTP endpoint responds with a successful payload containing a recording and its associated patient.
|
||||
/// Asserts that the returned items match the source data for status, room identifier, and patient identity fields.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a268bca body=27cf99d -->
|
||||
[Test]
|
||||
public async Task GetRecordings_Return_RecordingData()
|
||||
{
|
||||
@@ -187,6 +190,7 @@ public class RecordingServiceTest
|
||||
/// <summary>
|
||||
/// Tests that calling <c>SaveRequest</c> on the recording service throws a <see cref="NotImplementedException"/> when supplied with an <see cref="ApiRequest"/>, using a mocked HTTP message handler that returns a successful response.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e3a0b21 body=247c17b -->
|
||||
[Test]
|
||||
public Task SaveRequest()
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ public class RedisLockProviderTest
|
||||
/// <summary>
|
||||
/// Initializes the test environment by creating a mock <see cref="IDatabase"/> and instantiating a <see cref="RedisLockProvider"/> configured to use the mocked database.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d8eb19f body=aaffb29 -->
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -32,6 +33,7 @@ public class RedisLockProviderTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>AcquireAsync</c> returns <c>true</c>, stores the lock token under the <c>lock:</c> prefixed key, applies the configured TTL, and uses the <c>When.NotExists</c> flag when Redis accepts the NX SET operation. Also asserts that a subsequent <c>ReleaseAsync</c> invokes the Redis release script.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=70f9b70 body=cb5fcc3 -->
|
||||
[Test]
|
||||
public async Task AcquireAsync_ReturnsTrue_AndStoresToken_WhenRedisAcceptsNxSet()
|
||||
{
|
||||
@@ -78,6 +80,7 @@ public class RedisLockProviderTest
|
||||
/// Asserts the call is retried the expected number of times and that the elapsed time confirms
|
||||
/// delays were actually applied between attempts.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d11d703 body=9ec3583 -->
|
||||
[Test]
|
||||
public async Task AcquireAsync_RetriesWithDelays_UntilNxSucceeds()
|
||||
{
|
||||
@@ -112,6 +115,7 @@ public class RedisLockProviderTest
|
||||
/// <summary>
|
||||
/// Verifies that AcquireAsync returns <c>false</c> and performs multiple retry attempts when the underlying lock acquisition operation consistently fails within the specified timeout.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b5c5d4f body=131b234 -->
|
||||
[Test]
|
||||
public async Task AcquireAsync_ReturnsFalse_AfterTimeoutWithMultipleRetries()
|
||||
{
|
||||
@@ -142,6 +146,7 @@ public class RedisLockProviderTest
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a27fd67 body=af51113 -->
|
||||
[Test]
|
||||
public async Task ReleaseAsync_CallsScriptEvaluateWithCorrectKeyAndToken()
|
||||
{
|
||||
@@ -181,6 +186,7 @@ public class RedisLockProviderTest
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=34ada35 body=27f9924 -->
|
||||
[Test]
|
||||
public async Task ReleaseAsync_IsIdempotent_WhenCalledWithoutPriorAcquire()
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ public class RedisServiceTest
|
||||
/// <summary>
|
||||
/// Initializes test dependencies before each test execution by creating a mock <see cref="IDatabase"/> instance and instantiating the <see cref="LockManagerService"/> with a mocked logger and an in-memory lock provider.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d8eb19f body=f7d3912 -->
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -40,6 +41,7 @@ public class RedisServiceTest
|
||||
/// <param name="settings">Optional cache settings to apply; when <c>null</c>, a new default <see cref="CacheSettings"/> instance is used.</param>
|
||||
/// <param name="redisAvailable">Flag indicating whether the Redis service should be marked as available; defaults to <c>true</c>.</param>
|
||||
/// <returns>A <see cref="RedisService"/> instance with the database and availability state initialized for testing.</returns>
|
||||
/// <!-- aidoc:v1 sig=3b2c312 body=dfaacef -->
|
||||
private RedisService CreateSut(CacheSettings? settings = null, bool redisAvailable = true)
|
||||
{
|
||||
var sut = new RedisService(
|
||||
@@ -59,6 +61,7 @@ public class RedisServiceTest
|
||||
/// <param name="target">The <see cref="RedisService"/> instance whose field will be set.</param>
|
||||
/// <param name="name">The name of the non-public instance field to assign.</param>
|
||||
/// <param name="value">The value to assign to the field. Can be null.</param>
|
||||
/// <!-- aidoc:v1 sig=29fabd1 -->
|
||||
private static void SetField(object target, string name, object? value)
|
||||
=> typeof(RedisService)
|
||||
.GetField(name, BindingFlags.NonPublic | BindingFlags.Instance)!
|
||||
@@ -67,6 +70,7 @@ public class RedisServiceTest
|
||||
/// <summary>
|
||||
/// Configures the mock database to return a successful result (<c>true</c>) for any invocation of <c>StringSetAsync</c>, regardless of the supplied key, value, expiry, overwrite flag, condition, or command flags.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=98682b4 -->
|
||||
private void SetupStringSetAsync()
|
||||
=> _mockDb
|
||||
.Setup(db => db.StringSetAsync(
|
||||
@@ -77,6 +81,7 @@ public class RedisServiceTest
|
||||
/// <summary>
|
||||
/// Configures the mock Redis database to handle <c>KeyExpire</c> calls by returning <c>true</c> for any combination of key, expiration, condition, and command flag arguments.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0ffd573 -->
|
||||
private void SetupKeyExpire()
|
||||
=> _mockDb
|
||||
.Setup(db => db.KeyExpire(
|
||||
@@ -88,6 +93,7 @@ public class RedisServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>GetOrSetObjectAsync</c> invokes the supplied factory when Redis is unavailable, returning the factory's result without attempting any Redis read or write operations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1a73907 body=b6ad74e -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_ExecutesFactory_WhenRedisUnavailable()
|
||||
{
|
||||
@@ -111,6 +117,7 @@ public class RedisServiceTest
|
||||
/// when a value is present in the cache, without invoking the factory delegate and without
|
||||
/// attempting to write back to Redis.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ff045fa body=9481052 -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_ReturnsCachedObject_WhenRedisHit()
|
||||
{
|
||||
@@ -138,6 +145,7 @@ public class RedisServiceTest
|
||||
/// Verifies that <c>GetObjectAsync</c> calls the underlying Redis <c>KeyExpire</c> command with the configured TTL
|
||||
/// when the <c>updateExpiration</c> flag is set to <c>true</c>, ensuring cache entries are refreshed upon a successful hit.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=066b548 body=8421fd4 -->
|
||||
[Test]
|
||||
public async Task GetObjectAsync_CallsKeyExpire_WhenUpdateExpirationIsTrue()
|
||||
{
|
||||
@@ -167,6 +175,7 @@ public class RedisServiceTest
|
||||
/// Verifies that <c>GetObjectAsync</c> does not invoke the Redis key expiration command
|
||||
/// when the caller explicitly requests that the existing expiration be left unchanged.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e10e6a3 body=d0256b9 -->
|
||||
[Test]
|
||||
public async Task GetObjectAsync_DoesNotCallKeyExpire_WhenUpdateExpirationIsFalse()
|
||||
{
|
||||
@@ -190,6 +199,7 @@ public class RedisServiceTest
|
||||
/// Ensures the factory delegate is executed, the deserialized value matches the factory output, and the
|
||||
/// object is written to cache with the expected expiration.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=775bb73 body=a143def -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_InvokesFactoryAndPersists_WhenCacheMiss()
|
||||
{
|
||||
@@ -232,6 +242,7 @@ public class RedisServiceTest
|
||||
/// Verifies that when the cache lookup returns no value and the factory delegate produces <c>null</c>,
|
||||
/// the method returns <c>null</c> and does not persist any value to the underlying cache store.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=67a4b2b body=95662d2 -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_DoesNotPersist_WhenFactoryReturnsNull()
|
||||
{
|
||||
@@ -256,6 +267,7 @@ public class RedisServiceTest
|
||||
/// Verifies that <c>GetObjectAsync</c> successfully retrieves and deserializes the stored object while skipping the
|
||||
/// key-expiration refresh when <c>updateExpiration</c> is set to <c>false</c>, ensuring <c>KeyExpire</c> is never invoked.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f1dc303 body=114b61f -->
|
||||
[Test]
|
||||
public async Task GetObjectAsync_ReturnsObject_AndSkipsKeyExpire_WhenUpdateExpirationFalse()
|
||||
{
|
||||
@@ -280,6 +292,7 @@ public class RedisServiceTest
|
||||
/// Verifies that <c>SetObjectAsync</c> serializes the supplied object to JSON and persists it in Redis
|
||||
/// with the entity-specific TTL (600 seconds) configured for the "Patients" entity in <see cref="CacheSettings"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=053126b body=05a7fbb -->
|
||||
[Test]
|
||||
public async Task SetObjectAsync_SerializesToJson_AndPersistsWithEntityTtl()
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ public class RelayServiceTest
|
||||
/// <summary>
|
||||
/// Sets up the test environment by initializing mocks and dependencies required for unit testing the <see cref="RelayService"/>, including logger, HTTP client factory, HTTP message handler, relay settings, point-of-care service, and relay repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=f8dc12e -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -62,6 +63,8 @@ public class RelayServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the relay service successfully powers off a relay by issuing an HTTP request through the configured HTTP client factory.
|
||||
/// </summary>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "The summary claims the test 'verifies that the relay service successfully powers off a relay', but the test contains no assertions—it only sets up mocks and calls PowerOff without verifying any outcome." -->
|
||||
[Test]
|
||||
public async Task PowerOffAsync()
|
||||
{
|
||||
@@ -100,6 +103,7 @@ public class RelayServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="RelayService.PowerOn"/> correctly sends a power-on request to the configured relay device using the HTTP client.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=44fe1e4 body=914160c -->
|
||||
[Test]
|
||||
public async Task PowerOnAsync()
|
||||
{
|
||||
@@ -138,6 +142,7 @@ public class RelayServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>CheckRelayStatus</c> returns <see cref="RelayEnum.Status.On"/> when the mocked HTTP response indicates the relay is on.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2a547df body=bf57c2c -->
|
||||
[Test]
|
||||
public async Task CheckRelayStatus_Return_On()
|
||||
{
|
||||
@@ -226,6 +231,7 @@ public class RelayServiceTest
|
||||
/// driver response does not match a recognized on/off state (e.g., the raw payload "\\Off" is not
|
||||
/// mapped to a known status).
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=85fcbc2 body=fd57b78 -->
|
||||
[Test]
|
||||
public async Task CheckRelayStatus_Return_Unknown()
|
||||
{
|
||||
|
||||
@@ -348,6 +348,7 @@ public class SchedulerServiceTest
|
||||
/// Verifies that the <see cref="CheckInactivePatientsJob"/> is executed when its Quartz.NET trigger fires,
|
||||
/// ensuring the scheduled job invokes the patient discharge process for inactive patients at the configured interval.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=433f153 body=564acd0 -->
|
||||
[Test]
|
||||
public void CheckInactivePatientsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
@@ -387,6 +388,7 @@ public class SchedulerServiceTest
|
||||
/// when triggered, and that the medicine service is invoked exactly once to retrieve medicines
|
||||
/// for the active treatments of the mocked patients.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=01d636e body=f71f2df -->
|
||||
[Test]
|
||||
public void CheckActiveTreatmentsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
@@ -460,6 +462,7 @@ public class SchedulerServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="CheckExpiredObservationsJob"/> is executed at least once by the Quartz.NET scheduler when triggered with a recurring schedule.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=77a1a73 body=9a546f0 -->
|
||||
[Test]
|
||||
public void CheckExpiredObservationsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
@@ -493,6 +496,7 @@ public class SchedulerServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="CheckExpiredAlertsJob"/> is executed when triggered by the Quartz.NET scheduler, ensuring that the <c>ExpireAlertsAndPowerOffAsync</c> method on the observation service is invoked at least once.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0e98299 body=a3d213c -->
|
||||
[Test]
|
||||
public void CheckExpiredAlertsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
@@ -527,6 +531,7 @@ public class SchedulerServiceTest
|
||||
/// <c>InsertObservation</c> with a <see cref="PatientObservation"/> whose <c>Name</c> is not "NEWS", ensuring
|
||||
/// that only NEWS observations are considered for persistence during scheduled execution.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=efdce93 body=5423389 -->
|
||||
[Test]
|
||||
public void GetProvidersObservationsJob_ShouldExecuteOnTrigger_Result_GetType_null()
|
||||
{
|
||||
@@ -577,6 +582,7 @@ public class SchedulerServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="CalculateNewsJob"/> is executed when triggered by the Quartz.NET scheduler, confirming that the associated <c>InsertObservation</c> call on the observation service is invoked at least once within the allowed execution window.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2db113b body=674d8bd -->
|
||||
[Test]
|
||||
public void CheckCalculateNewsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
@@ -610,6 +616,7 @@ public class SchedulerServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculateNewsJob.Execute"/> correctly inserts NEWS observations with the expected calculated values (1 and 4) for multiple patients in a single execution.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a18d2b9 body=bc2ddd0 -->
|
||||
[Test]
|
||||
public async Task CalculateNewsJob_Insert_ObsFull_MultiplePatient_With_Correct_Value()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ public class SendAlertServiceTest
|
||||
/// RabbitMQ options, a mocked logger, an instance of the service under test, and the set
|
||||
/// of Windows platform identifiers used to validate platform-specific behavior.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=764cb7d -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -54,6 +55,7 @@ public class SendAlertServiceTest
|
||||
/// reading (non-null with a positive <c>ValueTotal</c>) when executed on a Windows platform. When the
|
||||
/// host operating system is not Windows, the test is skipped with an ignore notice.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=679f280 body=1dd0797 -->
|
||||
[Ignore("Integration test to pull request")]
|
||||
[Test]
|
||||
public void GetConsumedCpu_Return_PerformanceCpu_data()
|
||||
@@ -78,6 +80,7 @@ public class SendAlertServiceTest
|
||||
/// for <c>PercentageConsumed</c>, <c>ValueConsumed</c>, and <c>ValueTotal</c>. The test only executes on
|
||||
/// Windows platforms and is ignored on other operating systems.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7a39a99 body=abcb5c0 -->
|
||||
[Ignore("Integration test to pull request")]
|
||||
[Test]
|
||||
public void GetConsumedRAM_Return_PerformanceRAM_data()
|
||||
@@ -104,6 +107,7 @@ public class SendAlertServiceTest
|
||||
/// <summary>
|
||||
/// Integration test that verifies the GetConsumedStorage method returns valid Performance data with positive percentage and value metrics for all ready drives on Windows platforms. The test is ignored when executed on a non-Windows platform.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a2098e9 body=3485f79 -->
|
||||
[Ignore("Integration test to pull request")]
|
||||
[Test]
|
||||
public void GetConsumedStorage_Return_PerformanceStorage_data()
|
||||
|
||||
@@ -17,6 +17,7 @@ public class ServiceConfigServiceTest
|
||||
/// <summary>
|
||||
/// Initializes the test environment by creating mock instances of the service configuration repository and logger, and instantiating the <see cref="ServiceConfigService"/> under test.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=beef729 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -41,6 +42,7 @@ public class ServiceConfigServiceTest
|
||||
/// Verifies that the <see cref="ServiceConfig"/> service returns a <see cref="ServiceConfig"/> instance
|
||||
/// when retrieving an existing configuration by its string identifier.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9b53d80 body=c9ed65c -->
|
||||
[Test]
|
||||
public async Task Get_Find_Id_Return_ServiceConfig()
|
||||
{
|
||||
@@ -59,6 +61,7 @@ public class ServiceConfigServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the Get method returns a <see cref="ServiceConfig"/> when the specified id is not found by the repository's <c>FindById</c>, falling back to a lookup with any <see cref="ObjectId"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=575d813 body=2042ef1 -->
|
||||
[Test]
|
||||
public async Task Get_Not_Find_Id_Return_ServiceConfig()
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ public class TreatmentServiceTest
|
||||
/// <summary>
|
||||
/// Initializes the mock dependencies and creates a <see cref="TreatmentService"/> instance for unit testing.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=e1a20f3 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -183,6 +184,7 @@ public class TreatmentServiceTest
|
||||
/// Verifies that saving an <see cref="ApiRequest"/> without the Case option throws an <see cref="ApiRequestException"/>, preventing the insert operation.
|
||||
/// </summary>
|
||||
/// <exception cref="ApiRequestException">Thrown by the service when the Case option is not provided in the request.</exception>
|
||||
/// <!-- aidoc:v1 sig=e189a56 body=217df39 -->
|
||||
[Test]
|
||||
public void SaveRequest_Not_Case_option_Return_not_insert()
|
||||
{
|
||||
@@ -195,6 +197,7 @@ public class TreatmentServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that _treatmentService.SaveRequest throws an <see cref="ApiRequestException"/> when the <see cref="ApiRequest"/> is missing both the patient number and the point of care, preventing insertion of an incomplete request.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=641365f body=4992b53 -->
|
||||
[Test]
|
||||
public void SaveRequest_patientNumber_and_pointOfCare_null_Return_not_insert()
|
||||
{
|
||||
@@ -211,6 +214,7 @@ public class TreatmentServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that _treatmentService.SaveRequest does not insert a patient treatment record when the patient cannot be found in the archive.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=67b2be6 body=c16d218 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Not_Find_Patient_Return_not_insert()
|
||||
{
|
||||
@@ -239,6 +243,7 @@ public class TreatmentServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that SaveRequest does not insert a new patient treatment into the treatment archive when an existing patient is found by patient number.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2b730f8 body=b50d935 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Find_Patient_Return_insert()
|
||||
{
|
||||
@@ -278,6 +283,7 @@ public class TreatmentServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>GetActiveTreatmentsByPatient</c> retrieves the full set of active treatments for the specified patient, returning a non-empty collection that includes all expected treatment records identified by their placer order entity identifiers.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=94cf97f body=366612d -->
|
||||
[Test]
|
||||
public async Task GetActiveTreatmentsByPatient()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace adas_core.Test.Services;
|
||||
/// <remarks>
|
||||
/// This class is intended to contain test methods that validate the behavior and correctness of the UnitService.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=d7fe647 -->
|
||||
public class UnitServiceTest
|
||||
{
|
||||
private readonly Mock<ILocalAuditService> _auditServiceMock = new();
|
||||
@@ -35,6 +36,7 @@ public class UnitServiceTest
|
||||
/// Initializes mocked dependencies and a configured <see cref="UnitService"/> instance for each test,
|
||||
/// including a mock <see cref="HttpContext"/> with a test user claim.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d8eb19f body=9422220 -->
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -72,6 +74,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the unit service returns all units retrieved from the repository, including the correct count and content.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=646f078 body=e817121 -->
|
||||
[Test]
|
||||
public async Task GetAll_ShouldReturnAllUnits()
|
||||
{
|
||||
@@ -91,6 +94,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the Get method on the unit service returns the expected unit when a valid identifier is provided.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0b84cdc body=a6e9915 -->
|
||||
[Test]
|
||||
public async Task Get_ShouldReturnUnitById()
|
||||
{
|
||||
@@ -110,6 +114,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the Get method retrieves a unit by name when the provided identifier is not a valid ObjectId, matching against either the unit's Title or Name.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=27de124 body=d6052b8 -->
|
||||
[Test]
|
||||
public async Task Get_ShouldReturnUnitByName_WhenIdIsNotObjectId()
|
||||
{
|
||||
@@ -135,6 +140,7 @@ public class UnitServiceTest
|
||||
/// Verifies that _unitService" returns all units retrieved from the repository,
|
||||
/// ensuring the result is not null, contains the expected number of units, and matches the source data.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=58385af body=4797f02 -->
|
||||
[Test]
|
||||
public async Task GetAllUnits_ShouldReturnAllUnits()
|
||||
{
|
||||
@@ -159,6 +165,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that _unitService.FindById" returns the matching <see cref="Unit"/> when the repository locates it by id.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4ba7a3f body=5b6115c -->
|
||||
[Test]
|
||||
public async Task GetUnitById_ShouldReturnUnit_WhenFound()
|
||||
{
|
||||
@@ -179,6 +186,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>GetByName</c> returns the matching unit when a unit with the specified name exists in the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f3d4d6c body=e6fef50 -->
|
||||
[Test]
|
||||
public async Task GetUnitByName_ShouldReturnUnit_WhenFound()
|
||||
{
|
||||
@@ -199,6 +207,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that <c>FindByPatientId</c> returns the associated unit when the patient is found in an active (in-use) point of care.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c94d17c body=783cf46 -->
|
||||
[Test]
|
||||
public async Task FindUnitByPatientId_ShouldReturnUnit_WhenPatientFoundInActivePoC()
|
||||
{
|
||||
@@ -229,6 +238,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the unit service returns the matching units retrieved from the repository when a call is made to find units by the specified master list identifier and type.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=43926cf body=5d4a6ea -->
|
||||
[Test]
|
||||
public async Task FindUnitsByMasterListId_ShouldReturnUnits_WhenUnitsFound()
|
||||
{
|
||||
@@ -255,6 +265,7 @@ public class UnitServiceTest
|
||||
/// Verifies that the unit service returns the matching units when the repository contains units
|
||||
/// whose point of care matches the specified patient location.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f8afd28 body=15ba7bb -->
|
||||
[Test]
|
||||
public async Task FindByLocation_ShouldReturnUnits_WhenUnitsFound()
|
||||
{
|
||||
@@ -282,6 +293,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that FindByLocation returns an empty list when no units match the specified patient location.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fd09042 body=3dd5efa -->
|
||||
[Test]
|
||||
public async Task FindByLocation_ShouldReturnEmptyList_WhenNoUnitsFound()
|
||||
{
|
||||
@@ -301,6 +313,7 @@ public class UnitServiceTest
|
||||
/// Verifies that the unit service returns the expected unit when a valid unit identifier is provided.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=bd2f214 body=ccde6a3 -->
|
||||
[Test]
|
||||
public async Task FindById_ShouldReturnUnit_WhenValidIdProvided()
|
||||
{
|
||||
@@ -321,6 +334,7 @@ public class UnitServiceTest
|
||||
/// Verifies that the unit service's FindById method returns null when invoked with a null identifier,
|
||||
/// ensuring graceful handling of null input without throwing or returning a default entity.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=74278e6 body=91cce5c -->
|
||||
[Test]
|
||||
public async Task FindById_ShouldReturnNull_WhenNullIdProvided()
|
||||
{
|
||||
@@ -336,6 +350,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that FindByName retrieves and returns the expected <c>Unit</c> when a valid unit name is provided.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=25b0fc0 body=3bf0b69 -->
|
||||
[Test]
|
||||
public async Task FindByName_ShouldReturnUnit_WhenValidNameProvided()
|
||||
{
|
||||
@@ -356,6 +371,7 @@ public class UnitServiceTest
|
||||
/// <summary>
|
||||
/// Verifies that the unit service correctly delegates the insert operation to the repository and returns the inserted unit entity unchanged.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=24b4720 body=83a8f91 -->
|
||||
[Test]
|
||||
public async Task InsertOne_ShouldReturnInsertedUnit()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user