Documentation modifications

This commit is contained in:
julian
2026-06-27 15:23:26 -07:00
parent a633fe6c06
commit a19fb90902
218 changed files with 2882 additions and 0 deletions
@@ -10,6 +10,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that verifies the behavior of <see cref="AdmissionRepository"/>.
/// </summary>
/// <remarks>
/// Marked with <see cref="TestFixtureAttribute"/> and <see cref="CategoryAttribute"/> so the test runner identifies and groups these as integration-level tests.
/// </remarks>
/// <!-- aidoc:v1 sig=67f8e73 -->
[TestFixture]
[Category("Integration")]
public class AdmissionRepositoryTest
@@ -10,6 +10,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that validates the behavior of <see cref="AlarmRepository"/>.
/// </summary>
/// <remarks>
/// Annotated with <see cref="NUnit.Framework.TestFixtureAttribute"/>, <see cref="NUnit.Framework.OrderAttribute"/>, and <see cref="NUnit.Framework.CategoryAttribute"/> to control execution ordering and group the tests under the integration category.
/// </remarks>
/// <!-- aidoc:v1 sig=b6895d1 -->
[TestFixture]
[Order(1)]
[Category("Integration")]
@@ -9,6 +9,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Serves as an NUnit integration test fixture for the <see cref="AppointmentArchiveRepository"/> type.
/// </summary>
/// <remarks>
/// The Integration category groups these tests so they can be executed separately from unit tests, indicating they depend on external infrastructure beyond isolated components.
/// </remarks>
/// <!-- aidoc:v1 sig=308c8a6 -->
[TestFixture]
[Category("Integration")]
public class AppointmentArchiveRepositoryTest
@@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that verifies the behavior of <see cref="AppointmentRepository"/> against a real data store.
/// </summary>
/// <remarks>
/// Marked with the <c>Integration</c> test category, so the contained cases are excluded from fast unit-test runs and executed in the dedicated integration pipeline.
/// </remarks>
/// <!-- aidoc:v1 sig=561a0df -->
[TestFixture]
[Category("Integration")]
public class AppointmentRepositoryTest
@@ -9,6 +9,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Provides integration tests for the <see cref="ConfigObservationRepository"/>.
/// </summary>
/// <remarks>
/// Marked as a <see cref="TestFixtureAttribute"/> and grouped under the "Integration" <see cref="CategoryAttribute"/> to allow filtering of test runs.
/// </remarks>
/// <!-- aidoc:v1 sig=aa99020 -->
[TestFixture]
[Category("Integration")]
public class ConfigObservationRepositoryTest
@@ -7,6 +7,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that verifies the behavior of the ConfigPumpsRepository against real or external dependencies.
/// </summary>
/// <remarks>
/// Tagged with the Integration category so these tests can be selected or excluded independently of unit tests.
/// </remarks>
/// <!-- aidoc:v1 sig=245a994 -->
[TestFixture]
[Category("Integration")]
public class ConfigPumpsRepositoryTest
@@ -6,6 +6,12 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that verifies the behavior of <see cref="ConfigUnitsRepository"/>.
/// </summary>
/// <remarks>
/// Categorized as an integration test suite to group and selectively execute tests that exercise <see cref="ConfigUnitsRepository"/> against its backing store.</remarks>
/// <!-- aidoc:v1 sig=74d2637 -->
[TestFixture]
[Category("Integration")]
public class ConfigUnitsRepositoryTest
@@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that verifies the behavior of <see cref="DiagnosisArchiveRepository"/>.
/// </summary>
/// <remarks>
/// Tests in this fixture belong to the <c>Integration</c> category and exercise the repository against its real or staged persistence dependencies rather than pure unit-level mocks.
/// </remarks>
/// <!-- aidoc:v1 sig=e2e7845 -->
[TestFixture]
[Category("Integration")]
public class DiagnosisArchiveRepositoryTest
@@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Provides integration tests for the diagnosis repository.
/// </summary>
/// <remarks>
/// The class is decorated with <see cref="NUnit.Framework.TestFixtureAttribute"/> and <see cref="NUnit.Framework.CategoryAttribute"/> to mark it as an integration test fixture.
/// </remarks>
/// <!-- aidoc:v1 sig=cea30aa -->
[TestFixture]
[Category("Integration")]
public class DiagnosisRepositoryTest
@@ -9,6 +9,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Serves as the NUnit test fixture that contains integration tests for the <see cref="DischargeRepository"/>.
/// </summary>
/// <remarks>
/// Tests declared in this fixture are tagged with the <c>Integration</c> category, indicating they exercise the repository against its real infrastructure dependencies rather than mocked ones.
/// </remarks>
/// <!-- aidoc:v1 sig=42c809c -->
[TestFixture]
[Category("Integration")]
public class DischargeRepositoryTest
@@ -10,6 +10,13 @@ using Moq;
namespace adas_core.Test.Repositories;
/// <summary>
/// Test fixture that groups unit tests validating the behavior of <see cref="DisplayConfig"/>.
/// </summary>
/// <remarks>
/// Decorated with the <see cref="TestFixtureAttribute"/> so that its contained test methods are recognized and executed by the NUnit test runner.
/// </remarks>
/// <!-- aidoc:v1 sig=1b3c211 -->
[TestFixture]
public class DisplayConfigTest
{
@@ -1,5 +1,10 @@
namespace adas_core.Test.Repositories;
/// <summary>
/// Provides a test fixture for the display repository, containing test methods to verify its behavior.
/// Marked with <see cref="TestFixtureAttribute"/> to be recognized as an NUnit test fixture.
/// </summary>
/// <!-- aidoc:v1 sig=9ea7e41 -->
[TestFixture]
public class DisplayRepisitoryTest
{
@@ -11,6 +11,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Test fixture that exercises the <see cref="HistoricalConfigChangesRepository"/> through integration-level scenarios.
/// </summary>
/// <remarks>
/// Tests in this fixture are categorized as integration tests.
/// </remarks>
/// <!-- aidoc:v1 sig=0c6a022 -->
[TestFixture]
[Category("Integration")]
public class HistoricalConfigChangesRepositoryTest
@@ -5,6 +5,13 @@ using MongoDB.Driver;
namespace adas_core.Test.Repositories;
/// <summary>
/// Provides one-time setup and teardown for database-backed integration tests within the containing namespace or assembly.
/// </summary>
/// <remarks>
/// Decorated with the <see cref="SetUpFixtureAttribute"/> attribute so its initialization and cleanup members run a single time per scope, and classified under the "Integration" <see cref="CategoryAttribute"/>.
/// </remarks>
/// <!-- aidoc:v1 sig=cef7699 -->
[SetUpFixture]
[Category("Integration")]
public class IntegrationDb
@@ -7,6 +7,10 @@ using MongoDB.Bson;
namespace adas_core.Test.Repositories;
/// <summary>
/// Contains unit tests that exercise the behavior of the <see cref="MasterListRepository"/> class.
/// </summary>
/// <!-- aidoc:v1 sig=f765b7d -->
[TestFixture]
public class MasterListRepositoryTest
{
@@ -154,6 +158,10 @@ public class MasterListRepositoryTest
Assert.That(result?.Name, Is.EqualTo("FindById MasterList"));
}
/// <summary>
/// Verifies that the repository's <c>FindById</c> method returns the matching <see cref="MasterList"/> with locale-specific option names for each <see cref="LocaleEnum"/> value, falling back to the <c>DefaultLocale</c> when the requested locale has no translations (e.g., <see cref="LocaleEnum.Zh"/> falls back to <see cref="LocaleEnum.Es"/>), and that <see cref="OptionList.LocaleItems"/> is not populated on the returned options.
/// </summary>
/// <!-- aidoc:v1 sig=963d864 body=3b63175 -->
[Test]
public async Task FindById_WithDifferentLocale_ShouldReturnEntity_WhenFound()
{
@@ -209,6 +217,11 @@ public class MasterListRepositoryTest
Assert.That(resultEs?.Options[0].LocaleItems, Is.Null);
}
/// <summary>
/// Verifies that <see cref="FindById"/> returns the persisted <see cref="MasterList"/> entity for every requested <see cref="LocaleEnum"/> value, falling back to <see cref="MasterList.DefaultLocale"/> content when no locale-specific translations exist.
/// Confirms the lookup succeeds for <see cref="LocaleEnum.Zh"/>, <see cref="LocaleEnum.Pt"/>, <see cref="LocaleEnum.Eng"/>, <see cref="LocaleEnum.Ca"/>, and <see cref="LocaleEnum.Es"/>, returning the default-locale <see cref="OptionList"/> values in each case.
/// </summary>
/// <!-- aidoc:v1 sig=9d9832c body=3d01f48 -->
[Test]
public async Task FindById_WithDifferentLocale_ShouldReturnEntity_WhenFound_AndDefaultLocale()
{
@@ -284,6 +297,11 @@ public class MasterListRepositoryTest
Assert.That(result.Count(), Is.GreaterThanOrEqualTo(2));
}
/// <summary>
/// Tests that <c>GetMasterListByIdAndSearchOptions</c> correctly retrieves a <see cref="MasterList"/> by its identifier and filters its associated <see cref="OptionList"/> entries by locale-specific criteria.
/// Validates the search behavior across multiple supported locales (<see cref="LocaleEnum.Pt"/>, <see cref="LocaleEnum.Eng"/>, and <see cref="LocaleEnum.Es"/>), covering both <c>Text</c>-based and <c>Description</c>-based filters provided through <see cref="FilterOptionListElement"/>, and asserts that the returned option matches the expected localized name for each scenario.
/// </summary>
/// <!-- aidoc:v1 sig=6f8b09c body=234cc3c -->
[Test]
public async Task GetMasterListByIdAndSearchOptiionsByLocale()
{
@@ -323,6 +341,10 @@ public class MasterListRepositoryTest
Assert.That(resultEs[0].Name, Is.EqualTo("Opción 1"));
}
/// <summary>
/// Verifies that updating a <see cref="MasterList"/> option through <see cref="MasterListRepository.UpdateMasterListOption"/> for a specific <see cref="LocaleEnum"/> value replaces only the localized entry while preserving the default-locale option data.
/// </summary>
/// <!-- aidoc:v1 sig=c9c3b74 body=3bcdcc2 -->
[Test]
public async Task UpdateMasterListOptionByLocale()
{
@@ -365,6 +387,10 @@ public class MasterListRepositoryTest
// _pointOfCareRepositoryMock.Verify(m => m.FindById(patientLocationId), Times.Once);
}
/// <summary>
/// Tests that <see cref="_repository"/>.<see cref="_repository.FindOptionItemById(ObjectId, ObjectId, LocaleEnum)"/> returns the option item matching the supplied master list id, option id and locale, retrieving the localized name from the <see cref="Locale"/> entries (e.g. Portuguese) rather than the <see cref="MasterList.DefaultLocale"/>.
/// </summary>
/// <!-- aidoc:v1 sig=83783e8 body=2fb5717 -->
[Test]
public async Task FindOptionItemByLocaleAndId()
{
@@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that verifies the behavior of the medicine repository.
/// </summary>
/// <remarks>
/// Categorized as <c>Integration</c> to enable selective execution of the contained tests apart from unit-level suites.
/// </remarks>
/// <!-- aidoc:v1 sig=de33005 -->
[TestFixture]
[Category("Integration")]
public class MedicineRepositoryTest
@@ -64,6 +71,10 @@ public class MedicineRepositoryTest
Assert.That(result, Is.Empty);
}
/// <summary>
/// Verifies that <see cref="Repository{T}.GetMedicineByCodeOrNote"/> correctly retrieves a matching <see cref="Medicine"/> when both codes and notes are provided as search criteria, confirming that Paracetamol is returned when its code "605677" appears among the inputs.
/// </summary>
/// <!-- aidoc:v1 sig=e779a42 body=45093b5 -->
[Test]
public async Task Get_Medicines_Of_Treatments_By_Code_When_Have_Code_And_Notes_Return_Paracetamol()
{
@@ -12,6 +12,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that verifies MongoDB migration behavior.
/// </summary>
/// <remarks>
/// Marked with <see cref="TestFixtureAttribute"/> and <see cref="CategoryAttribute"/> using the "Integration" category to group it with other integration-level tests.
/// </remarks>
/// <!-- aidoc:v1 sig=c113d9c -->
[TestFixture]
[Category("Integration")]
public class MongodbMigrationTest
@@ -131,6 +138,10 @@ public class MongodbMigrationTest
Assert.That(ids, Does.Contain(10)); // 0.1.0
}
/// <summary>
/// Verifies that running migrations twice via the runner is idempotent and does not fail, and that the migration identified by id 10 remains present in the applied set returned by <c>GetAppliedMigrationIds</c> after the second <c>UpdateToLatest</c> execution.
/// </summary>
/// <!-- aidoc:v1 sig=e6dd929 body=b78ac59 -->
[Test]
public void RunningMigrationsTwice_ShouldNotFail()
{
@@ -9,10 +9,21 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Serves as an integration test fixture that exercises the behavior of <see cref="ObservationArchiveRepository"/> against a real backing store.
/// </summary>
/// <remarks>
/// Marked with <see cref="CategoryAttribute"/> set to <c>"Integration"</c>, indicating that the tests in this class require external dependencies and are grouped accordingly.
/// </remarks>
/// <!-- aidoc:v1 sig=ddbec50 -->
[TestFixture]
[Category("Integration")]
public class ObservationArchiveRepositoryTest
{
/// <summary>
/// One-time setup that resets the <c>archive_patients_observations</c> collection in the integration database and seeds it with two <see cref="PatientObservation"/> records (a current "Sin alergias conocidas" entry and a prior "¿Alergia al látex?" entry), both coded with the SNM system and marked as <see cref="StatusEnum.Type.Ok"/>, so that <see cref="ObservationArchiveRepository"/> integration tests start from a known baseline state.
/// </summary>
/// <!-- aidoc:v1 sig=81c0015 body=cc3ec40 -->
[OneTimeSetUp]
public async Task Init()
{
@@ -15,6 +15,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that validates the behavior of the <see cref="ObservationRepository"/> class against a real backing store.
/// </summary>
/// <remarks>
/// Marked with <see cref="CategoryAttribute"/> set to "Integration" and <see cref="OrderAttribute"/> set to 1 so the suite runs first among the integration tests.
/// </remarks>
/// <!-- aidoc:v1 sig=7a56957 -->
[TestFixture]
[Order(1)]
[Category("Integration")]
@@ -1940,6 +1947,10 @@ public class ObservationRepositoryTest
Assert.That(resultClear.ToList(), Has.Count.EqualTo(0));
}
/// <summary>
/// Verifies that <see cref="AggregatedPatientGroupedObservations"/> returns the expected aggregated list when grouping observations by <see cref="GroupedField.Name"/> and <see cref="GroupedField.Group"/> using <see cref="Regularity.Times"/> with <see cref="GroupedField.Result"/> set to <see cref="Result.First"/> and a maximum of 8 entries, inserting 30 observations and asserting the returned count is either 7 or 8 to account for possible cross-test interference.
/// </summary>
/// <!-- aidoc:v1 sig=4d50061 body=df81f59 -->
[Test]
public async Task AggregatedPatientGroupedObservations_Times_Firs_Return_List_8()
{
@@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that verifies the behavior of <see cref="PatientArchiveRepository"/>.
/// </summary>
/// <remarks>
/// Decorated with the NUnit <see cref="TestFixture"/> attribute and tagged with the Integration category, this class groups the test cases that exercise the repository end-to-end.
/// </remarks>
/// <!-- aidoc:v1 sig=8dc7826 -->
[TestFixture]
[Category("Integration")]
public class PatientArchiveRepositoryTest
@@ -11,6 +11,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Serves as an NUnit test fixture containing integration tests for the PatientRepository.
/// </summary>
/// <remarks>
/// Marked with the <c>TestFixture</c> attribute and grouped under the <c>Integration</c> test category.
/// </remarks>
/// <!-- aidoc:v1 sig=25261b6 -->
[TestFixture]
[Category("Integration")]
public class PatientRepositoryTest
@@ -6,6 +6,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that exercises the <see cref="PoCMappingRepository"/>.
/// </summary>
/// <remarks>
/// Categorized as <c>"Integration"</c>, the tests in this fixture validate the repository against an actual or near-real data source rather than purely mocked dependencies.
/// </remarks>
/// <!-- aidoc:v1 sig=13b6156 -->
[TestFixture]
[Category("Integration")]
public class PoCMappingRepositoryTest
@@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Test fixture that verifies the behavior of <see cref="PoCSettingsRepository"/>.
/// </summary>
/// <remarks>
/// Marked with <see cref="TestFixtureAttribute"/> so the NUnit test runner discovers and executes its contained test methods.
/// </remarks>
/// <!-- aidoc:v1 sig=fb7e359 -->
[TestFixture]
public class PoCSettingsRepositoryTest
{
@@ -10,6 +10,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Serves as the NUnit <see cref="TestFixtureAttribute"/> for integration tests of the <see cref="PointOfCareRepository"/>.
/// </summary>
/// <remarks>
/// Tests in this class are tagged with the <c>Integration</c> category via the <see cref="CategoryAttribute"/>.
/// </remarks>
/// <!-- aidoc:v1 sig=c5bf1c7 -->
[TestFixture]
[Category("Integration")]
public class PointOfCareRepositoryTests
@@ -8,6 +8,13 @@ using MongoDB.Driver;
namespace adas_core.Test.Repositories;
/// <summary>
/// Provides integration tests for the <see cref="PumpAlarmEventRepository"/>.
/// </summary>
/// <remarks>
/// Marked with the <c>Integration</c> category to allow it to be included or excluded as a group during test execution.
/// </remarks>
/// <!-- aidoc:v1 sig=4e55d75 -->
[TestFixture]
[Category("Integration")]
public class PumpAlarmEventRepositoryTest
@@ -161,6 +168,10 @@ public class PumpAlarmEventRepositoryTest
// -------------------------------------------------------------------
// FIND LAST BY DEVICE
// -------------------------------------------------------------------
/// <summary>
/// Verifies that the repository's <c>FindLastByDeviceIdAsync</c> method returns the most recent event for the specified device by comparing it against the event with the latest <c>Time</c> retrieved via <c>FindByDeviceIdAsync</c>.
/// </summary>
/// <!-- aidoc:v1 sig=eeea0f1 body=b86e923 -->
[Test]
public async Task FindLastByDeviceIdAsync_Works()
{
@@ -8,6 +8,13 @@ using MongoDB.Driver;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that validates the behavior of <see cref="PumpAlarmStateRepository"/>.
/// </summary>
/// <remarks>
/// All tests in this fixture belong to the Integration category and are expected to depend on external infrastructure.
/// </remarks>
/// <!-- aidoc:v1 sig=879ce74 -->
[TestFixture]
[Category("Integration")]
public class PumpAlarmStateRepositoryTest
@@ -141,6 +148,10 @@ public class PumpAlarmStateRepositoryTest
Assert.That(found, Is.Not.Null);
}
/// <summary>
/// Verifies that the upsert operation updates an existing active <see cref="PumpAlarmState"/> record instead of inserting a duplicate, replacing the previous <see cref="PumpAlarmState.LastUpdated"/> timestamp while ignoring the supplied <see cref="PumpAlarmState.Id"/>.
/// </summary>
/// <!-- aidoc:v1 sig=0dc3309 body=3185eb8 -->
[Test]
public async Task UpsertActiveAsync_UpdatesExisting()
{
@@ -273,6 +284,10 @@ public class PumpAlarmStateRepositoryTest
}
}
/// <summary>
/// Verifies that invoking the upsert operation twice with the same <see cref="PumpAlarmState"/> keeps the active alarm set unique per device, confirming the operation is idempotent and does not insert duplicate records.
/// </summary>
/// <!-- aidoc:v1 sig=24cec53 body=37f0fc6 -->
[Test]
public async Task UpsertActiveAsync_NoDuplicateOnRepeatedCalls()
{
@@ -9,10 +9,24 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that validates the behavior of the <c>PumpArchiveRepository</c> against its real dependencies rather than mocked collaborators.
/// </summary>
/// <remarks>
/// Categorized as <c>Integration</c> so it can be filtered separately from unit tests during test execution.
/// </remarks>
/// <!-- aidoc:v1 sig=c26548c -->
[TestFixture]
[Category("Integration")]
public class PumpArchiveRepositoryTest
{
/// <summary>
/// Performs one-time initialization for the test fixture by seeding two <see cref="PumpObservation"/>
/// records into the archive collection: one with the current timestamp and another with a timestamp
/// ten days in the past, enabling tests of the <see cref="PumpArchiveRepository"/> archive behavior
/// across different observation times.
/// </summary>
/// <!-- aidoc:v1 sig=81c0015 body=344b169 -->
[OneTimeSetUp]
public async Task Init()
{
@@ -8,6 +8,13 @@ using MongoDB.Driver;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture for the <see cref="PumpObservationRepository"/>.
/// </summary>
/// <remarks>
/// Marked with the <c>Integration</c> category, so these tests target interactions with external dependencies rather than isolated unit logic.
/// </remarks>
/// <!-- aidoc:v1 sig=c9f19af -->
[TestFixture]
[Category("Integration")]
public class PumpObservationRepositoryTest
@@ -21,6 +28,13 @@ public class PumpObservationRepositoryTest
// -------------------------------------------------------------------
// INIT SETUP DE LA COLECCIÓN CON DATOS DE PRUEBA
// -------------------------------------------------------------------
/// <summary>
/// One-time setup that prepares the integration test environment for the <see cref="PumpObservationRepository"/> by clearing the
/// <c>pump_observations</c> collection, recreating it, building the indexes, and seeding it with three sample <see cref="PumpObservation"/>
/// records belonging to <see cref="BasePatientObservation.PatientId"/>. The setup then asserts that exactly three documents were
/// inserted into the collection.
/// </summary>
/// <!-- aidoc:v1 sig=81c0015 body=162df76 -->
[OneTimeSetUp]
public async Task Init()
{
@@ -79,6 +93,10 @@ public class PumpObservationRepositoryTest
// -------------------------------------------------------------------
// FIND LAST OBSERVATIONS (LÍMITE = 2)
// -------------------------------------------------------------------
/// <summary>
/// Verifies that the repository returns exactly two observations for the specified patient and "PumpX", and that the returned list is ordered with the first observation's time greater than or equal to the second observation's time.
/// </summary>
/// <!-- aidoc:v1 sig=3214dea body=70daa63 -->
[Test]
public async Task FindLastObservations_ReturnsTwo()
{
@@ -92,6 +110,10 @@ public class PumpObservationRepositoryTest
// -------------------------------------------------------------------
// INSERT
// -------------------------------------------------------------------
/// <summary>
/// Verifies that <see cref="IRepository{PumpObservation}.InsertAsync"/> persists a new <see cref="PumpObservation"/> so that a subsequent lookup by <see cref="BasePatientObservation.Id"/> returns the stored entity.
/// </summary>
/// <!-- aidoc:v1 sig=2215003 body=9eae88d -->
[Test]
public async Task InsertAsync_Works()
{
@@ -109,6 +131,10 @@ public class PumpObservationRepositoryTest
Assert.That(found.FirstOrDefault(), Is.Not.Null);
}
/// <summary>
/// Verifies that the repository successfully inserts a batch of <see cref="PumpObservation"/> documents and that all items can be retrieved by their identifiers from the underlying collection.
/// </summary>
/// <!-- aidoc:v1 sig=5a5d3db body=8d0d26b -->
[Test]
public async Task InsertManyAsync_Works()
{
@@ -127,6 +153,10 @@ public class PumpObservationRepositoryTest
// -------------------------------------------------------------------
// FIND METHODS
// -------------------------------------------------------------------
/// <summary>
/// Verifies that the FindByDeviceIdAsync repository method returns a non-empty collection of pump observations for the specified device, ordered by time in descending order with the most recent observation first.
/// </summary>
/// <!-- aidoc:v1 sig=01527dc body=3a6c4b2 -->
[Test]
public async Task FindByDeviceIdAsync_ReturnsOrdered()
{
@@ -140,6 +170,10 @@ public class PumpObservationRepositoryTest
}
}
/// <summary>
/// Verifies that the repository's <c>FindByPatientAsync</c> call returns a non-empty collection of observations for the configured <c>PatientId</c>, ordered by time in descending order so that the most recent observation appears first.
/// </summary>
/// <!-- aidoc:v1 sig=1926bb1 body=010dd96 -->
[Test]
public async Task FindByPatientAsync_ReturnsOrdered()
{
@@ -153,6 +187,10 @@ public class PumpObservationRepositoryTest
}
}
/// <summary>
/// Verifies that <see cref="Repository.FindLastByDeviceIdAsync"/> returns a non-null observation whose <see cref="BasePatientObservation.DeviceId"/> matches the device identifier passed in.
/// </summary>
/// <!-- aidoc:v1 sig=eeea0f1 body=d0bcd5d -->
[Test]
public async Task FindLastByDeviceIdAsync_Works()
{
@@ -162,6 +200,10 @@ public class PumpObservationRepositoryTest
Assert.That(obs.DeviceId, Is.EqualTo("Device-A"));
}
/// <summary>
/// Verifies that the repository lookup by patient identifier returns a non-empty collection of results.
/// </summary>
/// <!-- aidoc:v1 sig=363130a body=c6821a0 -->
[Test]
public async Task FindByPatientId_Works()
{
@@ -173,6 +215,10 @@ public class PumpObservationRepositoryTest
// -------------------------------------------------------------------
// AGGREGATED LAST OBSERVATIONS
// -------------------------------------------------------------------
/// <summary>
/// Verifies that the aggregated last observations retrieved for the test <c>PatientId</c> are distinct by name, ensuring the resulting collection is non-empty and contains at most two entries.
/// </summary>
/// <!-- aidoc:v1 sig=878cf7b body=9a03f04 -->
[Test]
public async Task AggregatedPatientLastObservations_DistinctByName()
{
@@ -188,6 +234,10 @@ public class PumpObservationRepositoryTest
// -------------------------------------------------------------------
// DELETE METHODS
// -------------------------------------------------------------------
/// <summary>
/// Verifies that <see cref="PumpObservation"/> records associated with a given patient can be removed via <c>DeleteByPatientId</c>, ensuring no matching observations remain in the repository after deletion.
/// </summary>
/// <!-- aidoc:v1 sig=d53a759 body=16f0ddb -->
[Test]
public async Task DeleteByPatientId_Works()
{
@@ -207,6 +257,10 @@ public class PumpObservationRepositoryTest
Assert.That(list.Any(), Is.False);
}
/// <summary>
/// Tests that <c>DeleteOlderThanDaysAsync</c> successfully deletes pump observations older than the given number of days, asserting that the returned count is at least one when matching data exists.
/// </summary>
/// <!-- aidoc:v1 sig=eedf26a body=5bdb401 -->
[Test]
public async Task DeleteOlderThanDaysAsync_Works()
{
@@ -225,6 +279,11 @@ public class PumpObservationRepositoryTest
Assert.That(deleted, Is.GreaterThanOrEqualTo(1));
}
/// <summary>
/// Verifies that the older-observation pruning operation retains only the requested number of newest <see cref="PumpObservation"/> entries for the given name and returns the count of deleted items.
/// Inserts five timed observations and asserts that exactly three older entries are removed when two are kept.
/// </summary>
/// <!-- aidoc:v1 sig=d7625b7 body=dc1036f -->
[Test]
public async Task DeleteOlderNumberAsync_Works()
{
@@ -246,6 +305,10 @@ public class PumpObservationRepositoryTest
Assert.That(deleted, Is.EqualTo(3));
}
/// <summary>
/// Verifies that <see cref="_repo.DeleteKeepLastNAsync"/> correctly deletes the older records while preserving the most recent <paramref name="n"/> entries, returning the expected count of deleted items.
/// </summary>
/// <!-- aidoc:v1 sig=6f857ff body=814bec4 -->
[Test]
public async Task DeleteKeepLastNAsync_Works()
{
@@ -267,6 +330,10 @@ public class PumpObservationRepositoryTest
// -------------------------------------------------------------------
// UPDATE METHOD
// -------------------------------------------------------------------
/// <summary>
/// Verifies that <see cref="Repository{BasePatientObservation}.UpdateManyObjectIdByFieldAsync"/> correctly updates the <see cref="BasePatientObservation.PatientId"/> field of all matching records, replacing the old <see cref="MongoDB.Bson.ObjectId"/> value with a new one, and reports the number of documents modified.
/// </summary>
/// <!-- aidoc:v1 sig=e139730 body=639f796 -->
[Test]
public async Task UpdateManyObjectIdByFieldAsync_Works()
{
@@ -292,6 +359,12 @@ public class PumpObservationRepositoryTest
// -------------------------------------------------------------------
// AGGREGATION: LAST OBSERVATION TIME PER PATIENT
// -------------------------------------------------------------------
/// <summary>
/// Verifies that the repository returns a non-null dictionary containing the last patient observation
/// time for the specified patient, and that the recorded timestamp is not in the future relative to
/// <see cref="DateTime.UtcNow"/>.
/// </summary>
/// <!-- aidoc:v1 sig=1accf32 body=8a4a652 -->
[Test]
public async Task FindAllLastPatientObservationTimeAsync_Works()
{
@@ -305,6 +378,10 @@ public class PumpObservationRepositoryTest
}
}
/// <summary>
/// Verifies that looking up records by device ID with a date range entirely outside the stored data window returns an empty collection.
/// </summary>
/// <!-- aidoc:v1 sig=c885ffe body=2c99833 -->
[Test]
public async Task FindByDeviceIdAsync_EmptyWhenOutOfDateRange()
{
@@ -316,6 +393,10 @@ public class PumpObservationRepositoryTest
Assert.That(result, Is.Empty);
}
/// <summary>
/// Verifies that the repository's FindByPatientAsync method respects the <c>limit</c> parameter when retrieving records for a patient, asserting that the returned collection contains exactly one item when the limit is set to one.
/// </summary>
/// <!-- aidoc:v1 sig=4955050 body=a2ef54e -->
[Test]
public async Task FindByPatientAsync_RespectsLimit()
{
@@ -324,6 +405,10 @@ public class PumpObservationRepositoryTest
Assert.That(list, Has.Count.EqualTo(1));
}
/// <summary>
/// Verifies that FindLastByDeviceIdAsync returns null when no observation exists for the supplied device identifier.
/// </summary>
/// <!-- aidoc:v1 sig=275de54 body=b35493b -->
[Test]
public async Task FindLastByDeviceIdAsync_ReturnsNullWhenNotExists()
{
@@ -332,6 +417,10 @@ public class PumpObservationRepositoryTest
Assert.That(obs, Is.Null);
}
/// <summary>
/// Verifies that InsertManyAsync completes without throwing when invoked with an empty collection of <see cref="PumpObservation"/>.
/// </summary>
/// <!-- aidoc:v1 sig=a2eefa5 body=d0db476 -->
[Test]
public async Task InsertManyAsync_IgnoresEmptyList()
{
@@ -343,6 +432,10 @@ public class PumpObservationRepositoryTest
}
/// <summary>
/// Verifies that <c>DeleteOlderNumberAsync</c> leaves the stored data unchanged and returns zero when the total number of <see cref="PumpObservation"/> entries for the given device name is below the specified <c>maxCount</c> threshold.
/// </summary>
/// <!-- aidoc:v1 sig=934d0ad body=3bd6af8 -->
[Test]
public async Task DeleteOlderNumberAsync_DoesNothingWhenCountBelowLimit()
{
@@ -363,6 +456,10 @@ public class PumpObservationRepositoryTest
Assert.That(deleted, Is.Zero);
}
/// <summary>
/// Verifies that the repository cleanup operation preserves recent observations by inserting a <see cref="PumpObservation"/> whose timestamp is one minute in the past and asserting that the deletion count returned by <c>DeleteOlderThanDaysAsync</c> is zero.
/// </summary>
/// <!-- aidoc:v1 sig=1c414ad body=819234d -->
[Test]
public async Task DeleteOlderThanDaysAsync_DoesNotDeleteRecentObservations()
{
@@ -382,6 +479,10 @@ public class PumpObservationRepositoryTest
Assert.That(deleted, Is.Zero);
}
/// <summary>
/// Verifies that <see cref="AggregatedPatientLastObservations"/> deduplicates <see cref="PumpObservation"/> entries that share the same <see cref="PumpObservation.Code"/> and <see cref="PumpObservation.Name"/> for a given patient, returning only a single entry per code/name combination.
/// </summary>
/// <!-- aidoc:v1 sig=646e129 body=eebdec4 -->
[Test]
public async Task AggregatedPatientLastObservations_RemovesDuplicatesByCodeAndName()
{
@@ -8,6 +8,13 @@ using adas_core.Domain.Enums;
namespace adas_core.Test.Repositories;
/// <summary>
/// Serves as an integration test fixture that verifies the behavior of <see cref="PumpStateRepository"/>.
/// </summary>
/// <remarks>
/// Marked with <see cref="CategoryAttribute"/> set to <c>"Integration"</c>, the tests in this class exercise <see cref="PumpStateRepository"/> against its real dependencies rather than mocked collaborators.
/// </remarks>
/// <!-- aidoc:v1 sig=80c970c -->
[TestFixture]
[Category("Integration")]
public class PumpStateRepositoryTest
@@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Provides an integration test fixture that exercises the RecordingAlertArchiveRepository to verify its expected behavior.
/// </summary>
/// <remarks>
/// Categorized as "Integration" so it can be grouped with other integration tests during test execution.
/// </remarks>
/// <!-- aidoc:v1 sig=0394e16 -->
[TestFixture]
[Category("Integration")]
public class RecordingAlertArchiveRepositoryTest
@@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that validates the behavior of the RecordingAlertRepository class.
/// </summary>
/// <remarks>
/// Categorized as "Integration" to group it with other integration-level test fixtures.
/// </remarks>
/// <!-- aidoc:v1 sig=a26c3cb -->
[TestFixture]
[Category("Integration")]
public class RecordingAlertRepositoryTest
@@ -11,10 +11,23 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Serves as an integration test fixture for the SectionRepository type.
/// </summary>
/// <remarks>
/// Categorized as <c>"Integration"</c> via <see cref="CategoryAttribute"/> to group related test execution.
/// </remarks>
/// <!-- aidoc:v1 sig=b68ae8f -->
[TestFixture]
[Category("Integration")]
public class SectionRepositoryTest
{
/// <summary>
/// Initializes the integration test fixture by seeding two <see cref="Section"/> entities
/// (<c>UCIP1</c> and <c>UCIP2</c>) with their associated <see cref="Box"/> data into the
/// <c>config_sections</c> MongoDB collection through <see cref="SectionRepository"/>.
/// </summary>
/// <!-- aidoc:v1 sig=81c0015 body=44a9993 -->
[OneTimeSetUp]
public async Task Init()
{
@@ -83,6 +96,10 @@ public class SectionRepositoryTest
private static readonly ObjectId SectionId1 = ObjectId.GenerateNewId();
private static readonly ObjectId SectionId2 = ObjectId.GenerateNewId();
/// <summary>
/// Verifies that <see cref="_repository"/>.<see cref="GetAll"/> returns a non-null collection containing the expected number of <c>Sections</c>.
/// </summary>
/// <!-- aidoc:v1 sig=42e95a2 body=7729b1c -->
[Test]
public async Task GetAll_Return_List_Sections()
{
@@ -92,6 +109,10 @@ public class SectionRepositoryTest
Assert.That(result, Has.Count.EqualTo(2));
}
/// <summary>
/// Verifies that the repository's <c>FindBySection</c> method returns <see langword="null"/> when invoked with an empty section name, covering the not-found case for empty input.
/// </summary>
/// <!-- aidoc:v1 sig=2417a8d body=26e0f11 -->
[Test]
public async Task FindBySection_Not_Find_Return_null()
{
@@ -100,6 +121,10 @@ public class SectionRepositoryTest
Assert.That(result, Is.Null);
}
/// <summary>
/// Verifies that FindBySection returns a matching section record when queried by the title "UCI PEDIÁTRICA 2", ensuring the result is not <see langword="null"/> and the returned SectionTitle equals the queried value.
/// </summary>
/// <!-- aidoc:v1 sig=9ae4667 body=a76a58e -->
[Test]
public async Task FindBySection_Find_Return_Section()
{
@@ -109,6 +134,10 @@ public class SectionRepositoryTest
Assert.That(result!.SectionTitle, Is.EqualTo("UCI PEDIÁTRICA 2"));
}
/// <summary>
/// Verifies that the repository's FindByPointOfCare method returns <c>null</c> when invoked with an empty point of care value that does not match any existing record.
/// </summary>
/// <!-- aidoc:v1 sig=ba51c3a body=b62b9bf -->
[Test]
public async Task FindByPointOfCare_Not_Find_Return_null()
{
@@ -117,6 +146,10 @@ public class SectionRepositoryTest
Assert.That(result, Is.Null);
}
/// <summary>
/// Verifies that the repository's FindByPointOfCare method successfully retrieves a non-null section for the point of care identifier "UCIP1" and confirms that the returned section's SectionTitle equals "UCI PEDIÁTRICA 1".
/// </summary>
/// <!-- aidoc:v1 sig=0e320dc body=292d2c3 -->
[Test]
public async Task FindByPointOfCare_Find_Return_Section()
{
@@ -126,6 +159,10 @@ public class SectionRepositoryTest
Assert.That(result!.SectionTitle, Is.EqualTo("UCI PEDIÁTRICA 1"));
}
/// <summary>
/// Verifies that <see cref="FindById"/> returns <see langword="null"/> when the requested entity cannot be located, using an empty identifier to simulate the not-found scenario.
/// </summary>
/// <!-- aidoc:v1 sig=fd1f8c3 body=7ddac2c -->
[Test]
public async Task FindById_Not_Find_Return_null()
{
@@ -134,6 +171,11 @@ public class SectionRepositoryTest
Assert.That(result, Is.Null);
}
/// <summary>
/// Verifies that the repository's FindById method successfully retrieves a Section by its identifier, ensuring the returned object is not null and its SectionTitle matches the expected value.
/// Tests the lookup of the section with identifier "UCIP1" and asserts the returned title is "UCI PEDIÁTRICA 1".
/// </summary>
/// <!-- aidoc:v1 sig=4c116ce body=b30a392 -->
[Test]
public async Task FindById_Find_Return_Section()
{
@@ -143,6 +185,10 @@ public class SectionRepositoryTest
Assert.That(result!.SectionTitle, Is.EqualTo("UCI PEDIÁTRICA 1"));
}
/// <summary>
/// Verifies that invoking the repository's <c>FindById</c> with a freshly generated <see cref="MongoDB.Bson.ObjectId"/> that does not correspond to any stored entity returns <see langword="null"/>.
/// </summary>
/// <!-- aidoc:v1 sig=dcf9ad4 body=c6d06bf -->
[Test]
public async Task FindById_Not_Find_Id_Return_null()
{
@@ -151,6 +197,10 @@ public class SectionRepositoryTest
Assert.That(result, Is.Null);
}
/// <summary>
/// Verifies that the repository's FindById method successfully retrieves the section identified by SectionId2, confirming the returned section is not null and its SectionTitle equals "UCI PEDIÁTRICA 2".
/// </summary>
/// <!-- aidoc:v1 sig=15aea3b body=8a5a33f -->
[Test]
public async Task FindById_Find_Id_Return_Section()
{
@@ -160,6 +210,10 @@ public class SectionRepositoryTest
Assert.That(result!.SectionTitle, Is.EqualTo("UCI PEDIÁTRICA 2"));
}
/// <summary>
/// Verifies that the FindByLocation method returns a non-null empty list when no patient records match the specified PatientLocation.
/// </summary>
/// <!-- aidoc:v1 sig=e5d1cc6 body=8f2c7f5 -->
[Test]
public async Task FindByLocation_Not_Find_Return_Emty_List()
{
@@ -170,6 +224,10 @@ public class SectionRepositoryTest
Assert.That(result, Is.Empty);
}
/// <summary>
/// Tests that the repository's FindByLocation method returns a list with exactly one result for the specified <see cref="PatientLocation"/>, and that the returned record contains the expected section title.
/// </summary>
/// <!-- aidoc:v1 sig=4154fd5 body=4e74a65 -->
[Test]
public async Task FindByLocation_Find_Return_List()
{
@@ -182,6 +240,10 @@ public class SectionRepositoryTest
}
/// <summary>
/// Tests the insert, update, and delete lifecycle of a <see cref="Section"/> entity through the repository, verifying that a section can be inserted, retrieved by its identifier, updated with new content, and subsequently deleted.
/// </summary>
/// <!-- aidoc:v1 sig=1b52a18 body=59f8803 -->
[Test]
public async Task InsertUpdateAndDeleteSection()
{
@@ -7,6 +7,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture for verifying the behavior of <see cref="ServiceConfigRepository"/>.
/// </summary>
/// <remarks>
/// Categorized as an integration test to group it with other integration-level tests.
/// </remarks>
/// <!-- aidoc:v1 sig=e94d06f -->
[TestFixture]
[Category("Integration")]
public class ServiceConfigRepositoryTest
@@ -9,6 +9,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Acts as the integration test fixture for <see cref="TreatmentArchiveRepository"/>, containing tests that verify its behavior against real or test-managed external dependencies.
/// </summary>
/// <remarks>
/// The class is annotated with the Integration Category attribute, which groups its tests for selective execution and reporting distinct from unit tests.
/// </remarks>
/// <!-- aidoc:v1 sig=e875457 -->
[TestFixture]
[Category("Integration")]
public class TreatmentArchiveRepositoryTest
@@ -9,6 +9,14 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Serves as an integration test fixture that validates the behavior of the <see cref="TreatmentRepository"/>.
/// </summary>
/// <remarks>
/// Tests in this class are categorized as integration tests via the <see cref="CategoryAttribute"/> and require
/// the underlying data access infrastructure to be available at runtime.
/// </remarks>
/// <!-- aidoc:v1 sig=51e15dc -->
[TestFixture]
[Category("Integration")]
public class TreatmentRepositoryTest
@@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Integration test fixture that validates the behavior of the unit repository.
/// </summary>
/// <remarks>
/// Tagged with the Integration category to group it with other integration-level tests in the test suite.
/// </remarks>
/// <!-- aidoc:v1 sig=90c10c8 -->
[TestFixture]
[Category("Integration")]
public class UnitRepositoryTest
@@ -7,6 +7,10 @@ using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Repositories;
/// <summary>
/// Serves as an integration test fixture for <see cref="UserRepository"/>, exercising repository behavior against the real data store.
/// </summary>
/// <!-- aidoc:v1 sig=7aba773 -->
[TestFixture]
[Category("Integration")]
public class UserRepositoryTest