Documentation modifications
This commit is contained in:
@@ -12,10 +12,28 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Customizations.H12O.UCIN;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a test fixture that contains unit tests for calculated observations, executing with an order priority of 2 relative to other test fixtures.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This fixture is annotated with <see cref="TestFixtureAttribute"/> to mark it as a container of NUnit test methods, and with <see cref="OrderAttribute"/> to control its execution sequence within the test suite.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=d5b9e22 -->
|
||||
[TestFixture]
|
||||
[Order(2)]
|
||||
public class CalculatedObservationsTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the test fixture for <see cref="CalculatedObservations"/> by creating mocked instances of
|
||||
/// <see cref="IObservationService"/>, <see cref="IConfigObservationService"/>, <see cref="IMedicineService"/>,
|
||||
/// <see cref="ITreatmentService"/>, and <see cref="ILogger{CalculatedObservations}"/>, configuring
|
||||
/// <see cref="IOptions{TOptions}"/> settings for medication bolus, transcutaneous, regional brain saturation,
|
||||
/// electroencephalogram, respiratory, high-frequency ventilation, invasive ventilation, non-invasive
|
||||
/// ventilation, one-lung isolation, and ECMO codes, and registering all dependencies in a
|
||||
/// <see cref="ServiceCollection"/> so that a fully wired <see cref="CalculatedObservations"/> instance
|
||||
/// is produced for each test.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=3c4f27b -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -79,6 +97,10 @@ public class CalculatedObservationsTest
|
||||
|
||||
private IOptions<ApiSettings> _optionsApiSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that processing a new <see cref="PatientTreatment"/> that contains a medicine—matched by code to a known <see cref="Medicine"/> with an assigned <see cref="MedicineEnum.Types"/>—for the first time for a patient (no prior observations and no active treatments) results in a <see cref="PatientObservation"/> named <c>Medication</c> with value <c>1</c> associated to the treatment's <see cref="PatientTreatment.PatientId"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e86b69e body=2015ef3 -->
|
||||
[Test]
|
||||
public async Task Calculate_First_Medicine_Observation_With_Type_Should_Return_1()
|
||||
{
|
||||
@@ -128,6 +150,12 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a new <see cref="PatientTreatment"/> containing a medicine, when no prior
|
||||
/// observations or active treatments exist for the patient, results in the insertion of a
|
||||
/// <see cref="PatientObservation"/> named "Medication" with value <c>0</c> for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9a4b425 body=8e4c1db -->
|
||||
[Test]
|
||||
public async Task Calculate_First_Medicine_Observation_With_Out_Type_Should_Return_1()
|
||||
{
|
||||
@@ -176,6 +204,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a new <see cref="PatientTreatment"/> with an <c>OrderControl</c> of <see cref="OrderControlType.Nw"/> is mapped for the first time and contains a medicine code, a <see cref="PatientObservation"/> with name <c>Medication</c> and value <c>1</c> is inserted for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=58845f5 body=90a5eab -->
|
||||
[Test]
|
||||
public async Task Calculate__Medicine_Observation_New_Type_Should_Sum_1()
|
||||
{
|
||||
@@ -226,6 +258,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a new <see cref="PatientTreatment"/> is mapped and a prior <see cref="PatientObservation"/> of name "Medication" with value 0 already exists for the patient, the calculated observations service inserts a new observation with value 1 (the sum of the existing value 0 plus the new contribution).
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=cb5c407 body=b26efc0 -->
|
||||
[Test]
|
||||
public async Task Calculate__Medicine_Observation_Type_Already_Exists_Should_Sum_0()
|
||||
{
|
||||
@@ -296,6 +332,12 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a medicine observation of type <see cref="OrderControlType.Dc"/> already exists for the patient,
|
||||
/// <see cref="CalculatedObservations.Map(PatientTreatment)"/> subtracts the existing value and inserts a new observation with a resulting value of 0.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous unit test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=91b1fbb body=81816e9 -->
|
||||
[Test]
|
||||
public async Task Calculate__Medicine_Observation_DC_Type_Already_Exists_Should_Subtract_0()
|
||||
{
|
||||
@@ -357,6 +399,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="OrderControlType.Dc"/> treatment is processed and the patient has two active medicines, a <c>Medication</c> observation is inserted with the last observation value decremented by one (2 - 1 = 1).
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a244df0 body=151d371 -->
|
||||
[Test]
|
||||
public async Task Calculate__Medicine_Observation_DC_OF_TYPE_WITH_TWO_MEDICINES_Should_Subtract_0()
|
||||
{
|
||||
@@ -439,6 +485,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a new <see cref="PatientTreatment"/> containing a medicine without a defined type results in the insertion of a <see cref="PatientObservation"/> named "Medication" with a value of 1 for the associated patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9e218b6 body=fd802ff -->
|
||||
[Test]
|
||||
public async Task Calculate_Medicine_Observation_New_Medicine_Without_Type_Should_Insert_Medication_1_point()
|
||||
{
|
||||
@@ -514,6 +564,12 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="PatientObservation"/>.<see cref="PatientObservation.Map"/> inserts a new
|
||||
/// <see cref="PatientIntravenousLinesValue"/> observation with a score of <c>5</c> when processing the first
|
||||
/// intravenous arterial observation for a patient, given that no previous observations exist.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a3cd1e1 body=93b85d0 -->
|
||||
[Test]
|
||||
public async Task Calculate_First_Intravenous_Arterial_Observation_Should_Return_5()
|
||||
{
|
||||
@@ -550,6 +606,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a previous <see cref="PatientObservation"/> for the same patient and location has already been removed, the intravenous calculation performed by <see cref="CalculatedObservations.Map"/> produces a result of 0.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ca5324a body=aae89b4 -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_Obs_Already_Exist_Removed_Should_Return_0()
|
||||
{
|
||||
@@ -600,6 +660,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with an <see cref="PatientIntravenousLinesValue"/> whose type and location match the last stored observation for the same patient does not trigger an insertion of a calculated "IntravenousLines" observation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=076ddee body=f4d6ebd -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_two_observations_of_same_type_and_same_location_should_return_null()
|
||||
{
|
||||
@@ -647,6 +711,10 @@ public class CalculatedObservationsTest
|
||||
), true, true), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a new PatientObservation of type "IntravenousLinesObs" is processed alongside a previous observation of the same type for the same patient, the calculator produces a derived PatientObservation named "IntravenousLines" with a value of 10.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fd6a90d body=bae7c5e -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_two_observations_of_same_type_should_return_10()
|
||||
{
|
||||
@@ -696,6 +764,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="Map"/> method limits the calculated sum of <see cref="PatientIntravenousLinesValue"/> observations to a maximum value of ten when the total exceeds that threshold.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8681a17 body=b0efb6d -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_sum_more_than_10_should_limit_to_ten()
|
||||
{
|
||||
@@ -761,6 +833,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a new <see cref="PatientObservation"/> with a "Catéter línea media" type, when two prior intravenous lines exist (one "Catéter EPICUTÁNEO PERIFÉRICO" and one "Catéter Venoso PERIFÉRICO"), inserts an <see cref="PatientObservation"/> named "IntravenousLines" with a summed value of 5 for the given <paramref name="patientId"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1e74e0a body=1cc02b8 -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_sum_one_middle_line_and_two_Peripheral_should_return_5()
|
||||
{
|
||||
@@ -825,6 +901,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="_calculatedObservations"/>.<see cref="_calculatedObservations.Map"/> produces a monitor observation with value 3 for a treatment containing the EEG code <c>42803009</c>, based on the most recent transcutaneous and regional brain saturation observations retrieved for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a0a8af2 body=b1ce181 -->
|
||||
[Test]
|
||||
public async Task Calculate_Monitor_Transcuatenous_Regional_Brain_Saturation_and_enter_EEG_should_return_3()
|
||||
{
|
||||
@@ -896,6 +976,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a ventilation <see cref="PatientObservation"/> with value <c>OXIDO NITRICO 800 PPM MOL</c> for a patient with no prior observations produces a derived <see cref="PatientObservation"/> named "Respiratory" with an integer value of 10.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c24a7f7 body=316af0f -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_INO_should_return_10()
|
||||
{
|
||||
@@ -924,6 +1008,13 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="RespiratoryCalculations.Map"/> calculates a respiratory value of 5 when the patient observation
|
||||
/// represents a "V.A.F.O." (ventilación de alta frecuencia oscilatoria) entry coded as <c>361110005</c> in the SNM coding system,
|
||||
/// using an empty list returned by <see cref="IPatientObservationService.FindLastObservations"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> that completes when the assertions have been executed.</returns>
|
||||
/// <!-- aidoc:v1 sig=ff64ea1 body=e0741e9 -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_VAFO_should_return_5()
|
||||
{
|
||||
@@ -952,6 +1043,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with value "V.M.C." (ventilation type, SNOMED code "361110005") produces a calculated respiratory observation with value <c>3</c> for the same <see cref="PatientObservation.PatientId"/>, when no previous observations are returned by the observation service.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b50bb78 body=fbe450e -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_VMC_should_return_3()
|
||||
{
|
||||
@@ -980,6 +1075,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the ventilation type <c>V.N.I. Ciclada</c> (Non-Invasive Mechanical Ventilation) results in the insertion of a calculated respiratory observation with an integer value of <c>2</c> for the same patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8bbe6fe body=f6304b9 -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_VMNI_should_return_2()
|
||||
{
|
||||
@@ -1008,6 +1107,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientObservation"/> with name "Tipo de ventilación" and value "Bajo Flujo" is mapped, a calculated respiratory observation is inserted with value 1 for the associated patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dc95390 body=7ee3ef7 -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_Nassal_Canulas_Bajo_Flujo_should_return_2()
|
||||
{
|
||||
@@ -1036,6 +1139,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.Map"/> returns a respiratory value of 1 when the patient observation indicates an "Alto Flujo" (high flow nasal cannula) ventilation type, identified by <see cref="PatientObservation.Code"/> "361110005" in the SNM coding system.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=513d3e9 body=b065156 -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_Nassal_Canulas_Alto_Flujo_should_return_1()
|
||||
{
|
||||
@@ -1064,6 +1171,12 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the name "Resp_Mode" and the value "PC-AC"
|
||||
/// produces a calculated observation for "Resp_Type" using the "ADAS" coding system with the
|
||||
/// <see cref="RespirationType.Invasive"/> value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b5d9b6c body=e8d6f79 -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Returns_INVASIVE()
|
||||
{
|
||||
@@ -1085,6 +1198,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the name <c>Resp_Mode</c> and value <c>DUOPAP</c> triggers an insert of a new observation named <c>Resp_Type</c> using the <see cref="RespirationType.NonInvasive"/> value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f5e26c4 body=47ff0a9 -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Returns_NON_INVASIVE()
|
||||
{
|
||||
@@ -1106,6 +1223,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the <c>Resp_Mode</c> name and the <c>PC-HFO</c> value produces a calculated observation named <c>Resp_Type</c> using the <c>ADAS</c> coding system whose value resolves to <see cref="RespirationType.HighFrequencyVentilation"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0b62048 body=f640d1b -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Returns_HIGH_FREQUENCY()
|
||||
{
|
||||
@@ -1127,6 +1248,11 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientObservation"/> with <see cref="PatientObservation.Name"/> "Resp_Mode" and <see cref="PatientObservation.Value"/> "VENTAPNEA" is mapped, the calculated observation for "Resp_Type" is produced with <see cref="RespirationType.None"/> using the "ADAS" coding system.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=d1932f8 body=7b268e3 -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Returns_NONE()
|
||||
{
|
||||
@@ -1148,6 +1274,12 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that CalculateOxygenationIndex retrieves the latest AirPressure_Mean, FiO2, and PaO2
|
||||
/// <see cref="PatientObservation"/> values for the patient via FindLastObservations and inserts a new
|
||||
/// <see cref="PatientObservation"/> named "Oxygenation_Index" with the correctly computed value of 1250.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c1d2ff2 body=25f4ca1 -->
|
||||
[Test]
|
||||
public async Task CalculateOxygenationIndex_ShouldInsertCorrectObservation()
|
||||
{
|
||||
@@ -1178,6 +1310,13 @@ public class CalculatedObservationsTest
|
||||
It.IsAny<bool>(), It.IsAny<bool>()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CalculateAsistResp(BasePatientObservation)"/> inserts a new
|
||||
/// <see cref="PatientObservation"/> with the name <c>Respiratory</c> for the patient when the most recent
|
||||
/// retrieved observation matches the expected respiratory mode (<c>Resp_Mode</c>), and returns the
|
||||
/// original <paramref name="observation"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=52c29ce body=d802db9 -->
|
||||
[Test]
|
||||
public async Task CalculateAsistResp_ShouldUpdateObservation_WhenConditionsMet()
|
||||
{
|
||||
@@ -1215,6 +1354,13 @@ public class CalculatedObservationsTest
|
||||
// [TestCase("valorInvasive", RespirationType.INVASIVE)]
|
||||
// [TestCase("valorNonInvasive", RespirationType.NON_INVASIVE)]
|
||||
// [TestCase("valorNone", RespirationType.NONE)]
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculateVentilationMode"/> maps the supplied input value to the expected <see cref="RespirationType"/> and persists it as a <c>Resp_Type</c> observation via <see cref="PatientObservationService.InsertIfChanged"/>.
|
||||
/// Handles the localized input cases <c>valorHFV</c> (mapped to <c>PC-HFO</c>), <c>valorInvasive</c> (mapped to <c>PRVC</c>), and <c>valorNonInvasive</c> (mapped to <c>DUOPAP</c>); any other value falls back to <paramref name="expectedRespType"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The raw <c>Resp_Mode</c> input value from the observation; when it does not match a known ventilation label, it is replaced by <paramref name="expectedRespType"/>.</param>
|
||||
/// <param name="expectedRespType">The <see cref="RespirationType"/> expected to be inserted as <c>Resp_Type</c> after the calculation runs.</param>
|
||||
/// <!-- aidoc:v1 sig=f257d24 body=b077ba8 -->
|
||||
public async Task CalculateVentilationMode_ShouldInsertCorrectRespType(string value,
|
||||
RespirationType expectedRespType)
|
||||
{
|
||||
@@ -1246,6 +1392,16 @@ public class CalculatedObservationsTest
|
||||
// [TestCase("Age_Gestational", 1, 2, ObservationStatus.Alert)]
|
||||
// [TestCase("Age_Gestational", 1, 12, ObservationStatus.Ok)]
|
||||
// [TestCase("Age_Gestational_Fixed", 5, 10, ObservationStatus.Ok)]
|
||||
/// <summary>
|
||||
/// Verifies that the <c>CalculateTAmAlert</c> method updates the status of a <c>TAm</c> observation
|
||||
/// to the expected <see cref="StatusEnum.Type"/> when the observation name is "TAm", and inserts a new
|
||||
/// <c>TAm</c> observation when the name is "Age_Gestational" or "Age_Gestational_Fixed".
|
||||
/// </summary>
|
||||
/// <param name="observationName">The name of the observation under test, expected to be "TAm", "Age_Gestational", or "Age_Gestational_Fixed".</param>
|
||||
/// <param name="tamValue">The numeric TAm value assigned to the observation and related grouped observations.</param>
|
||||
/// <param name="gestationalAge">The numeric gestational age value used in the related grouped observations.</param>
|
||||
/// <param name="expectedType">The expected <see cref="StatusEnum.Type"/> used to assert the resulting observation status.</param>
|
||||
/// <!-- aidoc:v1 sig=8451823 body=20a4dd1 -->
|
||||
public async Task CalculateTAmAlert_ShouldUpdateStatusCorrectly(string observationName, int tamValue,
|
||||
int gestationalAge, StatusEnum.Type expectedType)
|
||||
{
|
||||
@@ -1306,6 +1462,10 @@ public class CalculatedObservationsTest
|
||||
It.Is<PatientObservation>(o => o.PatientId == patientId && o.Name == "TAm"),
|
||||
It.IsAny<bool>(), It.IsAny<bool>()));
|
||||
}
|
||||
/// <summary>
|
||||
/// Verifies that the ParseWeight method correctly converts the units to "gr" and scales the value (multiplying by 1000) when given a valid <see cref="PatientObservation"/> with a numeric <see cref="PatientObservation.Value"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dd3fee8 body=5df6de0 -->
|
||||
[Test]
|
||||
public async Task ParseWeight_WhenValidObservation_ShouldConvertUnitsAndValue()
|
||||
{
|
||||
@@ -1328,6 +1488,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that ParseWeight handles non-numeric <see cref="PatientObservation.Value"/> gracefully by returning the original <see cref="PatientObservation"/> unchanged.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e9945f6 body=ed7a0ab -->
|
||||
[Test]
|
||||
public async Task ParseWeight_WhenValueIsNotNumeric_ShouldHandleGracefullyAndReturnOriginal()
|
||||
{
|
||||
@@ -1339,6 +1503,10 @@ public class CalculatedObservationsTest
|
||||
Assert.That(result, Is.EqualTo(obs));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the ParseWeight method returns the original <see cref="BasePatientObservation"/> unchanged when the observation cannot be converted to a <c>PatientObservation</c>, exercising the fallback behavior for invalid input types.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=62502e3 body=f2a846f -->
|
||||
[Test]
|
||||
public async Task ParseWeight_WhenInvalidObservation_ShouldReturnOriginal()
|
||||
{
|
||||
@@ -1350,6 +1518,10 @@ public class CalculatedObservationsTest
|
||||
Assert.That(result, Is.EqualTo(obs));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when the patient temperature <see cref="PatientObservation"/> and the latest incubator temperature observation are both recent, <c>CalculateTempGradient</c> triggers an <c>InsertObservation</c> call exactly once to persist the computed <c>Temp_Gradient</c> value (incubator minus patient temperature).
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dadceb5 body=9a088dd -->
|
||||
[Test]
|
||||
public async Task CalculateTempGradient_WhenTempPatientAndTempIncubatorAreRecent_ShouldCalculateGradient()
|
||||
{
|
||||
@@ -1410,6 +1582,11 @@ public class CalculatedObservationsTest
|
||||
), Times.Once());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the temperature gradient calculation does not persist a new <see cref="PatientObservation"/>
|
||||
/// when the lookup for the complementary temperature reading returns no observations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=eb711fb body=d83838d -->
|
||||
[Test]
|
||||
public async Task CalculateTempGradient_WhenOneTemperatureIsMissing_ShouldNotCalculateGradient()
|
||||
{
|
||||
@@ -1437,6 +1614,10 @@ public class CalculatedObservationsTest
|
||||
), Times.Never()); // Verificamos que InsertObservation no se llama
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the intravenous line observation calculation maps <see cref="PatientObservation.Name"/> to "IntravenousLines", preserves <see cref="PatientObservation.PatientId"/>, and ensures <see cref="PatientObservation.Time"/> is not earlier than the current time when no prior intravenous lines observation exists.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6d30754 body=9402c27 -->
|
||||
[Test]
|
||||
public async Task CalculateIntravenousLineObservation_ShouldCalculateObservationAndAdjustTimeIfNecessary()
|
||||
{
|
||||
@@ -1474,6 +1655,10 @@ public class CalculatedObservationsTest
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CalculateMonitor(PatientObservation)"/> correctly calculates and inserts a "Monitor" <see cref="PatientObservation"/> when the patient has a valid existing observation matching the configured regional brain saturation code or an active treatment.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=489567e body=5acaf14 -->
|
||||
[Test]
|
||||
public async Task CalculateMonitor_WithValidObservationOrTreatment_ShouldCalculateAndInsertObservation()
|
||||
{
|
||||
@@ -1520,6 +1705,10 @@ public class CalculatedObservationsTest
|
||||
Times.Once());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <c>CalculateMonitor</c> calculates and inserts a new Monitor observation for the patient when invoked with a <see cref="PatientTreatment"/>, provided an active treatment exists and a matching non-expired <see cref="PatientObservation"/> is returned by <c>FindLastObservations</c>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4a87817 body=2f68585 -->
|
||||
[Test]
|
||||
public async Task CalculateMonitor_WithPatientTreatment_ShouldCalculateAndInsertObservation()
|
||||
{
|
||||
@@ -1565,6 +1754,13 @@ public class CalculatedObservationsTest
|
||||
Times.Once());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CalculateMonitor(PatientObservation)"/> does not invoke
|
||||
/// <see cref="ObservationService.InsertObservation(PatientObservation, bool, bool)"/> when the supplied
|
||||
/// <see cref="PatientObservation"/> contains incomplete data (only <see cref="BasePatientObservation.PatientId"/>
|
||||
/// is populated), and the prior observations returned by <see cref="ObservationService.FindLastObservations"/> are empty.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=62f5906 body=d3d0023 -->
|
||||
[Test]
|
||||
public async Task CalculateMonitor_WithIncompleteData_ShouldNotInsertObservation()
|
||||
{
|
||||
@@ -1594,6 +1790,10 @@ public class CalculatedObservationsTest
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the surgery expiration check does not insert the <see cref="PatientObservation"/> when its <see cref="PatientObservation.Expired"/> flag is set to <c>false</c>, ensuring that only expired observations trigger an insertion.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=51d7692 body=0f0f138 -->
|
||||
[Test]
|
||||
public async Task CheckSurgeryExpired_WhenNotExpired_DoesNotInsertObservation()
|
||||
{
|
||||
@@ -1608,6 +1808,10 @@ public class CalculatedObservationsTest
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that when a <see cref="PatientObservation"/> has expired, <see cref="CalculatedObservations.CheckSurgeryExpired(PatientObservation)"/> inserts a new <see cref="PatientObservation"/> named "Surgery" with value 0, range 0 to 5, coding system "ADAS", timestamp offset by one second from the original observation, and matching patient identifier and expiry duration.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ce416cc body=331e208 -->
|
||||
[Test]
|
||||
public async Task CheckSurgeryExpired_WhenExpired_InsertsCorrectObservation()
|
||||
{
|
||||
@@ -1634,6 +1838,10 @@ public class CalculatedObservationsTest
|
||||
), true, false), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CalculateComplexity"/> inserts a new complexity observation when processing a patient observation in a non-ECMO treatment context, ensuring the active treatments and recent observations are retrieved and the resulting complexity value is persisted.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=83462d4 body=c26dd24 -->
|
||||
[Test]
|
||||
public async Task CalculateComplexity_NewObservation_NoECMO_AddsComplexity()
|
||||
{
|
||||
@@ -1693,6 +1901,12 @@ public class CalculatedObservationsTest
|
||||
), true, false), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when an expired <see cref="PatientObservation"/> is passed to the complexity calculation,
|
||||
/// no new complexity record is inserted into the database, ensuring that expired observations are excluded
|
||||
/// from contributing to the patient's calculated complexity value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dbd49ea body=f99d711 -->
|
||||
[Test]
|
||||
public async Task CalculateComplexity_ExpiredObservation_DoesNotAddToComplexity()
|
||||
{
|
||||
@@ -1725,6 +1939,12 @@ public class CalculatedObservationsTest
|
||||
), true, true), Times.Never); // No se debe llamar InsertObservation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when an active treatment includes ECMO, <see cref="CalculatedObservations.CalculateComplexity(BasePatientObservation)"/>
|
||||
/// preserves the original <see cref="PatientObservation"/> value and records a derived <c>Complexity</c> observation labeled
|
||||
/// "1 ECMO" for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=188c976 body=8b97b7c -->
|
||||
[Test]
|
||||
public async Task CalculateComplexity_ECMOActive_AdjustsComplexity()
|
||||
{
|
||||
@@ -1784,6 +2004,10 @@ public class CalculatedObservationsTest
|
||||
), true, false), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CheckObsExistsAndIncrementTime"/> increments the <see cref="BasePatientObservation.Time"/> by one second beyond the existing observation when the lookup returns a <see cref="PatientObservation"/> sharing the same timestamp, patient, and observation name as the supplied instance.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4530eaf body=d89050c -->
|
||||
[Test]
|
||||
public async Task CheckObsExistsAndIncrementTime_SameHourObservation_IncrementsTime()
|
||||
{
|
||||
@@ -1823,6 +2047,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CheckObsWithSameTimeExistsAndIncrementTime"/> increments the <see cref="BasePatientObservation.Time"/> of the supplied <see cref="PatientObservation"/> by one second and assigns a new <see cref="BasePatientObservation.Id"/> when another observation with the same time and <see cref="BasePatientObservation.Name"/> already exists for the same <see cref="BasePatientObservation.PatientId"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3e1e2ae body=5370e25 -->
|
||||
[Test]
|
||||
public async Task CheckObsWithSameTimeExistsAndIncrementTime_WhenObservationWithSameTimeExists_IncrementsTime()
|
||||
{
|
||||
@@ -1869,6 +2097,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CheckTreatmentMedicines"/> correctly processes a treatment whose notes contain a parental nutrition formulation (comment "NPT" with comment type "formularybaseformulation"), looking up the associated <see cref="Medicine"/> by code, retrieving active treatments and the last medication observation for the patient, and inserting a new <see cref="PatientObservation"/> with <see cref="BasePatientObservation.Name"/> "Medication", <see cref="BasePatientObservation.CodingSystem"/> "ADAS" and <see cref="BasePatientObservation.Value"/> 1.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=28e758c body=0996b61 -->
|
||||
[Test]
|
||||
public async Task CheckTreatmentMedicines_ProcessesTreatmentCorrectly_WithParentalNutritionMedicine()
|
||||
{
|
||||
|
||||
@@ -13,6 +13,13 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Customizations.HPAZ;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a NUnit test fixture that hosts unit tests verifying the behavior of calculated observations.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The class is marked with the <see cref="TestFixtureAttribute"/> attribute to group test methods that validate calculated observation logic.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=ce3e368 -->
|
||||
[TestFixture]
|
||||
public class CalculatedObservationsTest
|
||||
{
|
||||
@@ -832,6 +839,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PumpObservation"/> with a null drug name and <see cref="PumpEnum.AlarmType.Occlusion"/> results in an inserted position name formatted as "Rack 1 Bomba 2".
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=23bca88 body=2889a88 -->
|
||||
[Test]
|
||||
public async Task Map_PumpObservation_DrugName_Null_AlarmType_Occlusion_Return_Insert_Pump_Insert_PositionName()
|
||||
{
|
||||
@@ -882,6 +893,10 @@ public class CalculatedObservationsTest
|
||||
arg.Value.ToString() == "Rack 1 Bomba 2"), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PumpObservation"/> with a null drug name, <see cref="PumpEnum.AlarmType.Occlusion"/> alarm, and <see cref="PumpObservation.IsAux"/> set to true produces an insertion of the main pump observation and an auxiliary observation with a position name formatted as "Rack Aux {GatewayNumber} Bomba {Number}".
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6ae491c body=5178203 -->
|
||||
[Test]
|
||||
public async Task
|
||||
Map_PumpObservation_DrugName_Null_AlarmType_Occlusion_Return_Insert_Pump_Insert_Aux_PositionName()
|
||||
|
||||
@@ -13,9 +13,20 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Customizations.HRYC;
|
||||
|
||||
/// <summary>
|
||||
/// Provides an NUnit test fixture that verifies the behavior of calculated observations.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Decorated with <see cref="TestFixtureAttribute"/> to mark the class as a container for related NUnit test methods that exercise calculated observation logic.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=ce3e368 -->
|
||||
[TestFixture]
|
||||
public class CalculatedObservationsTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the test environment for <see cref="CalculatedObservations"/> by mocking <see cref="IObservationService"/>, <see cref="IPatientService"/>, <see cref="ILightBeaconService"/>, and <see cref="IConfigObservationService"/>, configuring the latter to look up NEWS alert configurations by <see cref="PatientObservation.Name"/> and return <see langword="null"/> when no entry matches, registering all dependencies through a <see cref="ServiceCollection"/>, and providing a sample <see cref="Patient"/> resolved by its <see cref="Patient.Id"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=439c7b9 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -113,6 +124,10 @@ public class CalculatedObservationsTest
|
||||
private ObjectId _patientUnitId = ObjectId.GenerateNewId();
|
||||
private Patient _patient;
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with <c>NEWS</c> coding, when the resolved <see cref="ConfigObservation"/> enables a beacon alarm with <see cref="AlarmEnum.BeaconColor.None"/>, triggers the light beacon service to send <see cref="LightBeaconColor.Off"/> to the patient's <see cref="BasePatientObservation.PointOfCareId"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e823ca6 body=65dc365 -->
|
||||
[Test]
|
||||
public async Task Calculate_CheckBeaconOnNEWS_Should_Send_PowerOff()
|
||||
{
|
||||
@@ -148,6 +163,10 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientObservation"/> with the "NEWS" name, "ADAS" coding system, and a value of 6 is processed, and the resolved <see cref="ConfigObservation"/> enables a yellow beacon alarm, the <see cref="LightBeaconService"/> is invoked exactly once to send <see cref="LightBeaconColor.Yellow"/> to the patient's point of care.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=aa7e929 body=e6fe577 -->
|
||||
[Test]
|
||||
public async Task Calculate_CheckBeaconOnNEWS_Should_Send_Yellow()
|
||||
{
|
||||
@@ -183,6 +202,10 @@ public class CalculatedObservationsTest
|
||||
LightBeaconColor.Yellow), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientObservation"/> using the NEWS coding system is mapped and the resolved configuration defines an enabled red beacon alarm, the light beacon service is invoked exactly once to send the red color to the patient's point of care.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=843f672 body=55f19b1 -->
|
||||
[Test]
|
||||
public async Task Calculate_CheckBeaconOnNEWS_Should_Send_Red()
|
||||
{
|
||||
@@ -219,6 +242,10 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="_calculatedObservations"/>.Map correctly produces a <see cref="PatientObservation"/> with name <c>NEWS_EXTR_HI_Resp_Rate</c>, coding system <c>ADAS</c>, and the same numeric value as the supplied respiratory rate (<c>FR</c>) when the latest ventilator rate, <c>SpO2</c> and <c>FiO2</c> observations are available.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=49f263a body=aad4daf -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_FR_Returns_NEWS_EXTR_HI_Resp_Rate()
|
||||
@@ -270,6 +297,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> named <c>FR</c> with an invalid (non-numeric) value does not produce a NEWS_EXTR_HI respiratory rate result and instead raises a <see cref="FormatException"/>, even when valid <c>Vent_Rat</c>, <c>SpO2</c>, and <c>FiO2</c> observations are available for the same patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=80e9384 body=260f9f8 -->
|
||||
[Test]
|
||||
public async Task Calculate_FR_Does_Not_Returns_NEWS_EXTR_HI_Resp_Rate_When_Invalid_Value()
|
||||
{
|
||||
@@ -321,6 +352,15 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a respiratory rate (<c>FR</c>) observation through
|
||||
/// <see cref="ICalculatedObservations.Map(PatientObservation, bool)"/> produces a
|
||||
/// <c>NEWS_HI_Resp_Rate</c> observation with the expected value (<c>23</c>) and coding system
|
||||
/// (<c>ADAS</c>), resolving the ventilator rate (<c>Vent_Rat</c>), <c>SpO2</c>, and <c>FiO2</c>
|
||||
/// inputs via the mocked <see cref="IObservationService.FindLastObservations"/> calls and inserting
|
||||
/// the result through <see cref="IObservationService.InsertObservation"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=36eec84 body=c350cc3 -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_FR_Returns_NEWS_HI_Resp_Rate()
|
||||
@@ -377,6 +417,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies (under the legacy NEWS calculation path, currently ignored via <see cref="IgnoreAttribute"/>) that mapping a respiratory rate (<c>FR</c>) <see cref="PatientObservation"/> produces an inserted <c>NEWS_EXTR_LO_Resp_Rate</c> observation tagged with the <c>ADAS</c> coding system and carrying the same numeric value, using mocked supporting observations for ventilation rate (<c>Vent_Rate</c>) and oxygenation (<c>SpO2</c>, <c>FiO2</c>).
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4fa8ea2 body=f8aaeaa -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_FR_Returns_NEWS_EXTR_LO_Resp_Rate()
|
||||
@@ -433,6 +477,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with an SpO2 value of 90 produces an inserted <see cref="PatientObservation"/> named <c>NEWS_EXTR_LO_SpO2</c> using the <c>ADAS</c> coding system, by mocking the lookup of the last <c>FiO2</c> and <c>FR</c> observations for the same <see cref="PatientObservation.PatientId"/>. The test is annotated with <c>[Ignore]</c> because it targets the legacy NEWS calculation logic.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=937a891 body=deafefb -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_SpO2_Returns_NEWS_EXTR_LO_SpO2()
|
||||
@@ -471,6 +519,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a SpO2 <see cref="PatientObservation"/> produces a NEWS Low SpO2 score <see cref="PatientObservation"/> with name "NEWS_LO_SpO2", coding system "ADAS", and a value reflecting the source SpO2 reading (93), while relying on the last available respiratory rate (FR) observation for the calculation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=686d725 body=e5019f8 -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_SpO2_Returns_NEWS_LO_SpO2()
|
||||
@@ -509,6 +561,11 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> whose <see cref="BasePatientObservation.Name"/> is <c>Temperature</c> results in a derived <see cref="PatientObservation"/> named <c>NEWS_EXTR_LO_Temperature</c>, coded under the <c>ADAS</c> system, and carrying the original numeric <see cref="BasePatientObservation.Value"/>.
|
||||
/// Marked with <see cref="IgnoreAttribute"/> because it covers the legacy NEWS calculation logic.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=34bdb7c body=0b6d2c3 -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_Temperature_Returns_NEWS_EXTR_LO_Temperature()
|
||||
@@ -534,6 +591,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a high <see cref="PatientObservation"/> with name "Temperature" and value 40 produces a calculated NEWS high-temperature observation (<c>NEWS_HI_Temperature</c>) under the <c>ADAS</c> coding system.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2cfd40e body=7a7791e -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_Temperature_Returns_NEWS_HI_Temperature()
|
||||
@@ -559,6 +620,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the name "TAs" produces an associated low NEWS extra observation named "NEWS_EXTR_LO_TAs" in the ADAS coding system, carrying the same numeric value as the source observation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=32954ae body=a546520 -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_TAs_Returns_NEWS_EXTR_LO_TAs()
|
||||
@@ -584,6 +649,11 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <c>TAs</c> (systolic blood pressure) <see cref="PatientObservation"/> is mapped, a derived <c>NEWS_LO_TAs</c> observation is inserted with the expected <see cref="PatientObservation.CodingSystem"/> and <see cref="PatientObservation.Value"/>.
|
||||
/// This test is currently ignored because it targets the old NEWS calculation logic.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a6cacee body=6089652 -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_TAs_Returns_NEWS_LO_TAs()
|
||||
@@ -609,6 +679,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> named "TAs" with a value of 240 produces an inserted observation named "NEWS_EXTR_HI_TAs" under the "ADAS" coding system through <see cref="_calculatedObservations"/>. The test is currently ignored as it covers the old NEWS calculation logic.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1b56dd6 body=7a377a8 -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_TAs_Returns_NEWS_EXTR_HI_TAs()
|
||||
@@ -634,6 +708,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the name "FC" and a value of 20 produces an inserted calculated observation named "NEWS_EXTR_LO_FC" using the "ADAS" coding system, where the inserted value matches the original value of 20.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=58742a8 body=f2f71c1 -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_FC_Returns_NEWS_EXTR_LO_FC()
|
||||
@@ -659,6 +737,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with a heart rate (FC) value of 140 through the calculation pipeline produces a derived NEWS extra-high heart rate (<c>NEWS_EXTR_HI_FC</c>) observation carrying the same value and tagged with the ADAS coding system.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1eb9206 body=e721300 -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_FC_Returns_NEWS_EXTR_HI_FC()
|
||||
@@ -684,6 +766,11 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> named "FC" with value 120 produces a derived "NEWS_HI_FC" observation that is inserted through the observation service under the "ADAS" coding system with the original value preserved.
|
||||
/// The test is marked as ignored because it targets the legacy NEWS calculation flow.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2bf5811 body=3387162 -->
|
||||
[Ignore("old NEWS calc")]
|
||||
[Test]
|
||||
public async Task Calculate_FC_Returns_NEWS_HI_FC()
|
||||
@@ -709,6 +796,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that during the pre-mapping of a list of <see cref="PatientObservation"/> items, any observation named <c>MDC_VENT_RESP_RATE</c> (code <c>151586</c>) is removed from the resulting list and inserted as a separate observation via <see cref="IObservationService.InsertObservation"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fb56de1 body=f339d1c -->
|
||||
[Test]
|
||||
public async Task Check_MDC_VENT_RESP_RATE_IsInsertedBefore_And_RemoveFromList()
|
||||
{
|
||||
@@ -769,6 +860,10 @@ public class CalculatedObservationsTest
|
||||
obs.Code == "151586"), true, true), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when <see cref="PatientObservation"/> mapping processes a respiratory-rate observation alongside a preceding vent-rate observation returned by <see cref="IObservationService.FindLastObservations"/>, the calculated respiratory-rate observation is inserted with its <see cref="PatientObservation.Time"/> offset by one second from the source observation and with its <see cref="PatientObservation.ParentData"/> populated from the vent-rate observation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c5af3a7 body=2299b03 -->
|
||||
[Test]
|
||||
public async Task
|
||||
Check_Insert_Resp_Rate_Calculated_HasTimePlusOneSecond_And_Resp_Rate_Calculated_HasVentRateAsParent()
|
||||
@@ -816,6 +911,14 @@ public class CalculatedObservationsTest
|
||||
obs.Time == nowPlusOneSecond), true, true), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a patient observation with the name <c>Resp_Mode</c> and value <c>PC-AC</c>
|
||||
/// through <see cref="_calculatedObservations"/>.Map produces a calculated observation named
|
||||
/// <c>Resp_Type</c> using the <c>ADAS</c> coding system with the value
|
||||
/// <see cref="RespirationType.Invasive"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous unit test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=480e248 body=e8d6f79 -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Should_Return_INVASIVE()
|
||||
{
|
||||
@@ -838,6 +941,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> for respiratory mode with a non-invasive ventilation value produces a calculated <c>Resp_Type</c> observation classified as <see cref="RespirationType.NonInvasive"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=11ecdaa body=7ef6d7b -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Should_Return_NON_INVASIVE()
|
||||
{
|
||||
@@ -861,6 +968,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> whose <see cref="PatientObservation.Name"/> is "Resp_Mode" and <see cref="PatientObservation.Code"/> is "HNF" causes the calculation service to insert an observation with the <see cref="PatientObservation.Name"/> "Resp_Type", the <see cref="PatientObservation.CodingSystem"/> "ADAS", and the <see cref="PatientObservation.Value"/> set to <see cref="RespirationType.HighFrequencyVentilation"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=64e7ba4 body=1553933 -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Should_Return_HIGH_FREQUENCY()
|
||||
{
|
||||
@@ -985,6 +1096,10 @@ public class CalculatedObservationsTest
|
||||
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the mapping logic computes a diuresis-to-weight ratio of 43.6 from a diuresis observation of 3924 and a weight observation of 90 for the same patient, inserting the result as a new <see cref="PatientObservation"/> named "Diuresis_Weight".
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=5a47059 body=df4b18b -->
|
||||
[Test]
|
||||
public async Task CalculateDiuresis_Weight_Received_D_3924_W_90_Return_43_6()
|
||||
{
|
||||
@@ -1018,6 +1133,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="_calculatedObservations"/>.<see cref="ICalculatedObservations.Map(PatientObservation, bool)"/> correctly computes the diuresis-to-weight ratio as 43.6 when the latest diuresis observation value is 3924 and the current weight observation value is 90, and persists a derived <see cref="PatientObservation"/> named "Diuresis_Weight" for the same <paramref name="patientId"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b46e7fe body=50dd2ac -->
|
||||
[Test]
|
||||
public async Task CalculateDiuresis_Weight_D_3924_Receive_W_90_Return_43_6()
|
||||
{
|
||||
@@ -1051,6 +1170,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientObservation"/> with the name <c>Weight_Current</c> is received but no prior diuresis observations exist for the patient, the mapping does not insert any calculated observation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7c61653 body=30e7115 -->
|
||||
[Test]
|
||||
public async Task CalculateDiuresis_Weight_Received_W_90_D_Null_Return_Nothing()
|
||||
{
|
||||
@@ -1073,6 +1196,10 @@ public class CalculatedObservationsTest
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when <see cref="PatientObservation.Map"/> receives a Diuresis observation with value 3924 and the lookup for the last observation returns no results, the calculated "Diuresis_Weight" observation is not inserted.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7539e9b body=c0f4109 -->
|
||||
[Test]
|
||||
public async Task CalculateDiuresis_Weight_Received_D_3924_W_Null_Return_Nothing()
|
||||
{
|
||||
@@ -1097,6 +1224,10 @@ public class CalculatedObservationsTest
|
||||
), true, true), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> named "AllergiesObs" containing an empty list of <see cref="PatientAllergiesValue"/> produces a calculated <see cref="PatientObservation"/> named "Allergies" with an empty string value for the given patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=aabc273 body=af29e9f -->
|
||||
[Test]
|
||||
public async Task CalculateAllergiesObservation_Received_AllergiesObs_Emty_Return_Allergies_Emty()
|
||||
{
|
||||
@@ -1121,6 +1252,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> named "AllergiesObs" that contains non-pharmacological allergies (such as "Latex" and "Alergia ambiental") results in the insertion of an "Allergies" observation whose value is the uppercase, comma-separated concatenation of the allergy types (e.g., "LATEX, AMBIENTAL").
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=87f619d body=739c72a -->
|
||||
[Test]
|
||||
public async Task CalculateAllergiesObservation_Received_AllergiesObs_Without_Farmacos_Return_Allergies()
|
||||
{
|
||||
@@ -1161,6 +1296,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.Map(PatientObservation, bool)"/> consolidates a received <c>AllergiesObs</c> <see cref="PatientObservation"/> containing one drug allergy (fármacos), a latex allergy, and an environmental allergy into a single <see cref="PatientObservation"/> named <c>Allergies</c> for the same <see cref="PatientObservation.PatientId"/>, with the values merged into the formatted string <c>LATEX, AMBIENTAL, FÁRMACOS (METILPREDNISOLONA)</c>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6202c3a body=ca57051 -->
|
||||
[Test]
|
||||
public async Task CalculateAllergiesObservation_Received_AllergiesObs_With_1_Farmacos_Return_Allergies()
|
||||
{
|
||||
@@ -1208,6 +1347,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculateAllergiesObservation"/> aggregates a received <c>AllergiesObs</c> observation containing multiple allergy types — including two drug allergies (<c>METILPREDNISOLONA</c> and <c>Penicilina/cefalosporinas</c>), a latex allergy and an environmental allergy — into a single <see cref="PatientObservation"/> named <c>Allergies</c>, whose value combines the allergy categories and the drug allergens into the expected grouped string.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=661f407 body=8eae86e -->
|
||||
[Test]
|
||||
public async Task CalculateAllergiesObservation_Received_AllergiesObs_With_2_Farmacos_Return_Allergies()
|
||||
{
|
||||
@@ -1261,6 +1404,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientObservation"/> carrying a <see cref="PatientDrainagesValue"/> of type "Drenaje ventricular" with volume 60 and height 8 is processed by the calculator, two derived observations are inserted: one named "DVE" carrying the volume value and another named "Drainage_Height" carrying the height value, both under the "ADAS" coding system.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0c97fe5 body=b098a53 -->
|
||||
[Test]
|
||||
public async Task Calculate_Drainages_Received_volume_60_height_8_Return_DVE_height()
|
||||
{
|
||||
@@ -1298,6 +1445,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> carrying a <see cref="PatientDrainagesValue"/> of type "Drenaje ventricular" with a volume of 60 and no height produces a "DVE" observation while suppressing the "Drainage_Height" observation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b24ca90 body=c070bf1 -->
|
||||
[Test]
|
||||
public async Task Calculate_Drainages_Received_volume_60_height_null_Return_DVE()
|
||||
{
|
||||
@@ -1332,6 +1483,12 @@ public class CalculatedObservationsTest
|
||||
), true, true), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientObservation"/> containing a <see cref="PatientDrainagesValue"/>
|
||||
/// has a null received volume but a defined height (8), the mapping inserts a new observation named "Drainage_Height"
|
||||
/// with the height value while not creating a "DVE" observation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9f6bb92 body=73e12d9 -->
|
||||
[Test]
|
||||
public async Task Calculate_Drainages_Received_volume_null_height_8_Return_height()
|
||||
{
|
||||
@@ -1366,6 +1523,11 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that mapping a <see cref="PatientObservation"/> of drainages type with null volume and null height values
|
||||
/// does not generate any calculated <c>DVE</c> or <c>Drainage_Height</c> observations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ff5bb6d body=bf2607d -->
|
||||
[Test]
|
||||
public async Task Calculate_Drainages_Received_volume_null_height_null_Return_nothing()
|
||||
{
|
||||
|
||||
@@ -13,6 +13,13 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Customizations.HUVH.UCIA;
|
||||
|
||||
/// <summary>
|
||||
/// Test fixture that validates the behavior of <see cref="CalculatedObservationsTest"/> related functionality within the test suite.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Marked with <c>TestFixture</c> and assigned <c>Order(2)</c> to control its execution sequence relative to other fixtures.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=d5b9e22 -->
|
||||
[TestFixture]
|
||||
[Order(2)]
|
||||
public class CalculatedObservationsTest
|
||||
@@ -298,6 +305,10 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the mapping logic inserts a calculated ventilation mode observation when an <c>Air_Flow</c> <see cref="PatientObservation"/> is processed and the patient's coding system is <c>CCC</c>, ensuring the insert call is triggered exactly once.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=20f6c3b body=3db2e9e -->
|
||||
[Test]
|
||||
public async Task CalculateVentilationMode_Should_Insert_When_AirFlow_Arrives_And_CCC_Mode()
|
||||
{
|
||||
@@ -488,6 +499,10 @@ public class CalculatedObservationsTest
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the over-analgesia calculation does not create a new <see cref="PatientObservation"/> when the required conditions are not met: the source observation value falls below the expected threshold and the patient has no active <see cref="PatientTreatment"/>s.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8fad758 body=1678766 -->
|
||||
[Test]
|
||||
public async Task CalculateOverAnalgesia_Should_Not_Create_Observation_When_Conditions_Are_Not_Met()
|
||||
{
|
||||
@@ -547,6 +562,10 @@ public class CalculatedObservationsTest
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that driving pressure is not calculated nor persisted through <see cref="CalculatedObservations.Map"/> when the complementary <see cref="PatientObservation"/> required for the calculation is missing for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=5427d69 body=8449228 -->
|
||||
[Test]
|
||||
public async Task CalculateDrivingPressure_Should_Not_Calculate_If_Observation_Is_Missing()
|
||||
{
|
||||
@@ -603,6 +622,13 @@ public class CalculatedObservationsTest
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the ROX index mapping operation does not persist a calculated
|
||||
/// <see cref="PatientObservation"/> when the required complementary observation
|
||||
/// (needed to compute the ratio) cannot be retrieved, ensuring the calculation
|
||||
/// is skipped instead of being stored with incomplete data.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6d25e04 body=89d4d97 -->
|
||||
[Test]
|
||||
public async Task CalculateRoxIndex_Should_Not_Calculate_If_Observation_Is_Missing()
|
||||
{
|
||||
|
||||
@@ -13,9 +13,20 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace adas_core.Test.Customizations.HUVH.UCIN;
|
||||
|
||||
/// <summary>
|
||||
/// Test fixture that contains unit tests for the <see cref="CalculatedObservations"/> type.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Marked with <c>TestFixture</c> so that the NUnit test runner discovers and executes the contained test methods.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=ce3e368 -->
|
||||
[TestFixture]
|
||||
public class CalculatedObservationsTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the mocked dependencies and configuration required to instantiate <see cref="CalculatedObservations"/> for unit tests, including observation, medicine, and treatment services, the logger, and an <see cref="IOptions{ApiSettings}"/> populated with mapping interventions and complexity observation values deserialized from JSON.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=89278f9 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -1468,6 +1479,10 @@ public class CalculatedObservationsTest
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a new "Intervention_In" observation is mapped via <c>Map</c> and the patient's prior "Respiratory_Device_Multivalue" observation is expired (so there is no existing active last observation), a new <see cref="PatientObservation"/> named "Respiratory_Device_Multivalue" is inserted containing the new intervention while the existing expired observation is left untouched.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4271f27 body=7d4a79d -->
|
||||
[Test]
|
||||
public async Task Map_WithNewInterventionNoExistingLastIntervention_NewMultiValueObservation()
|
||||
{
|
||||
@@ -1519,6 +1534,13 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a new <c>Intervention_In</c> observation is mapped for a patient that already has an
|
||||
/// active <c>Respiratory_Device_Multivalue</c> observation, the new intervention is appended to the existing
|
||||
/// multi-value observation via <see cref="IObservationService.UpdateObservation"/> rather than inserted as a
|
||||
/// new record through <see cref="IObservationService.InsertObservation"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4e3257d body=697676f -->
|
||||
[Test]
|
||||
public async Task Map_WithNewInterventionAddsToExistingMultiValueObservation()
|
||||
{
|
||||
@@ -1805,6 +1827,12 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the <c>Map</c> method persists a "Complexity" <see cref="PatientObservation"/> with value 5
|
||||
/// when an "Intravenous_Routes_Multivalue" entry of "VV central" (contributing 2) and a "Respiratory_Device_Multivalue"
|
||||
/// entry of "Ventilación mecánica Invasiva" (contributing 3) are provided, summing their mapped complexity contributions.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2e89a15 body=4e1ae0e -->
|
||||
[Test]
|
||||
public async Task Map_WithIntravenousRoutesAndRespiratoryDeviceMultiValueObservation_CalculatesComplexity_Return5()
|
||||
{
|
||||
@@ -1944,6 +1972,13 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="PatientObservation"/> values mapped through the calculated observations pipeline
|
||||
/// produce a <c>Complexity</c> observation with value <c>4</c> when a newborn weight observation of <c>600</c>
|
||||
/// is provided and no previous observations exist for the respiratory, intravenous, medication, system,
|
||||
/// or surgery multivalue categories.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bdf12e7 body=260627c -->
|
||||
[Test]
|
||||
public async Task Map_WithNewbornWeightObservation_CalculatesComplexity_Return4()
|
||||
{
|
||||
@@ -2034,6 +2069,10 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that <see cref="CalculateSaturation.Map"/> inserts a diff observation with the calculated difference and a combined pre/post observation when a pre-observation is provided and the matching post-observation is found through <see cref="IObservationService.FindLastObservations"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1391042 body=6df8725 -->
|
||||
[Test]
|
||||
public async Task CalculateSaturation_DiffObservation_WhenPreObservationExistsAndPostIsFound_InsertsDiffAndPrePost()
|
||||
{
|
||||
@@ -2082,6 +2121,10 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a post observation is processed and a matching pre observation is found, both a diff observation (with the computed difference value) and a combined pre/post observation (with the pre and post values) are inserted.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b6cc196 body=fb6ab5b -->
|
||||
[Test]
|
||||
public async Task CalculateSaturation_DiffObservation_WhenPostObservationExistsAndPreIsFound_InsertsDiffAndPrePost()
|
||||
{
|
||||
@@ -2130,6 +2173,10 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.Map(PatientObservation)"/> does not insert new <see cref="PatientObservation"/> records when only the pre-observation is available for the patient and no matching post-observation is returned by <see cref="IObservationService.FindLastObservations"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fc1b349 body=1b524a8 -->
|
||||
[Test]
|
||||
public async Task CalculateSaturation_DiffObservation_WhenOnlyPreObservationExists_DoesNotInsertNewObservations()
|
||||
{
|
||||
@@ -2161,6 +2208,12 @@ public class CalculatedObservationsTest
|
||||
x => x.InsertObservation(It.IsAny<PatientObservation>(), It.IsAny<bool>(), It.IsAny<bool>()), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <c>CalculateSaturation</c> for a diff observation does not insert new
|
||||
/// <see cref="PatientObservation"/> entries when only the post-observation is found and the
|
||||
/// pre-observation is missing, ensuring no fallback insert occurs in this scenario.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c544665 body=5c5be3e -->
|
||||
[Test]
|
||||
public async Task CalculateSaturation_DiffObservation_WhenOnlyPostObservationExists_DoesNotInsertNewObservations()
|
||||
{
|
||||
@@ -2192,6 +2245,10 @@ public class CalculatedObservationsTest
|
||||
x => x.InsertObservation(It.IsAny<PatientObservation>(), It.IsAny<bool>(), It.IsAny<bool>()), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the saturation difference calculation correctly handles pre and post <see cref="PatientObservation"/> values that differ, producing a "SpO2_Diff" observation with the numeric difference (7.4) and a "SpO2_Pre_Post" observation with both values formatted as "99,5/92,1".
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f1e8f91 body=ed06b26 -->
|
||||
[Test]
|
||||
public async Task CalculateSaturation_DiffObservation_WithDifferentPrePostValues_CalculatesCorrectDifference()
|
||||
{
|
||||
@@ -2240,6 +2297,14 @@ public class CalculatedObservationsTest
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when mapping a pre-observation whose <see cref="PatientObservation.Value"/> is non-numeric, the
|
||||
/// <c>CalculateSaturation</c> logic treats the pre-value as 0 when computing the difference against the latest
|
||||
/// matching post-observation returned by <see cref="IObservationService.FindLastObservations"/>.
|
||||
/// Confirms that a <c>SpO2_Diff</c> observation is inserted with the value <c>0 - post</c> rounded to two decimals,
|
||||
/// and a <c>SpO2_Pre_Post</c> observation is inserted concatenating the raw pre-value and post-value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=36a4380 body=95adfa9 -->
|
||||
[Test]
|
||||
public async Task CalculateSaturation_DiffObservation_WithNonNumericPreValue_TreatsAsZero()
|
||||
{
|
||||
@@ -2382,6 +2447,11 @@ public class CalculatedObservationsTest
|
||||
x => x.InsertObservation(It.IsAny<PatientObservation>(), It.IsAny<bool>(), It.IsAny<bool>()), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientTreatment"/> whose <see cref="PatientTreatment.EndTime"/> is set yields a result with <see cref="OrderControlType.Dc"/>, overriding the order control that would otherwise be derived from the patient's previously active treatments.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> that completes when the assertions have been evaluated.</returns>
|
||||
/// <!-- aidoc:v1 sig=c43f82e body=7d24ee8 -->
|
||||
[Test]
|
||||
public async Task Map_TreatmentWithEndTimeSet_OverridesOrderControlFromOldTreatments()
|
||||
{
|
||||
@@ -2406,6 +2476,10 @@ public class CalculatedObservationsTest
|
||||
Assert.That(result.OrderControl, Is.EqualTo(OrderControlType.Dc));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the map operation inserts an observation when the supplied <see cref="PatientTreatment"/> carries a medication code. The test arranges a treatment with a single requested give code, configures the treatment, medicine, and observation services to return an existing active treatment list, the matching <see cref="Medicine"/>, and no previous observations; then asserts that the resulting <see cref="OrderControlType"/> is <see cref="OrderControlType.Xo"/> and that the observation service is invoked once with a <see cref="PatientObservation"/> whose name equals "Medication_Multivalue" and whose value is a <see cref="String"/> array of length one containing the medication text.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=cc4c529 body=a5d79cd -->
|
||||
[Test]
|
||||
public async Task Map_TreatmentWithMedication_InsertObservation()
|
||||
{
|
||||
|
||||
@@ -9,6 +9,10 @@ using static adas_core.Domain.Models.GroupedObservation;
|
||||
|
||||
namespace adas_core.Test.Models.SignalR;
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a test fixture that validates the grouped subscription behavior.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=efd17ec -->
|
||||
[TestFixture]
|
||||
public class SubscriberGroupedTest
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -38,6 +38,10 @@ public class AdmissionServiceTest
|
||||
private Mock<ISubscribersService> _subscribersServiceMock;
|
||||
private Mock<IUnitService> _unitServiceMock;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes mocked dependencies and constructs an <see cref="AdmissionService"/> instance for use in unit tests, configuring a mock <see cref="IHttpContextAccessor"/> with an authenticated test user.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=4512c25 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
||||
@@ -44,6 +44,10 @@ public class AlarmServiceTest
|
||||
private readonly RecordingSettings _recordingSettings = new();
|
||||
private readonly Mock<IUnitService> _unitServiceMock;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a test fixture that exercises <see cref="AlarmService"/>. The fixture configures mocked collaborators (such as <see cref="IAlarmRepository"/>, <see cref="IObservationService"/>, <see cref="IPatientService"/>, and <see cref="ILogger{AlarmService}"/>) and constructs an <see cref="AlarmService"/> instance with the background timer disabled for testing.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e109274 body=c40c5e2 -->
|
||||
public AlarmServiceTest()
|
||||
{
|
||||
var optionsApiSettings = Options.Create(_apiSettings);
|
||||
|
||||
@@ -42,6 +42,10 @@ public class FakeLockProvider : ILockProvider
|
||||
/// </remarks>
|
||||
public class FakeLockManagerService : LockManagerService
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="FakeLockManagerService"/>, a test fake of <see cref="LockManagerService"/>, by forwarding a mocked <see cref="ILogger{LockManagerService}"/> and a <see cref="FakeLockProvider"/> to the base constructor.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1d9bbc1 body=4448e1d -->
|
||||
public FakeLockManagerService() : base(
|
||||
Mock.Of<ILogger<LockManagerService>>(),
|
||||
new FakeLockProvider())
|
||||
@@ -61,6 +65,10 @@ public class FakeRedisService : RedisService, ICacheService
|
||||
public bool WasCalled { get; private set; }
|
||||
public string? LastKey { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="FakeRedisService"/>, a test double for <see cref="RedisService"/>, supplying default <see cref="CacheSettings"/>, a mocked <see cref="ILogger{RedisService}"/>, and a <see cref="FakeLockManagerService"/> to the base constructor.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=82d8847 body=4448e1d -->
|
||||
public FakeRedisService() : base(
|
||||
Options.Create(new CacheSettings()),
|
||||
Mock.Of<ILogger<RedisService>>(),
|
||||
@@ -123,10 +131,23 @@ public class FakeCacheService : CacheService, ICacheService
|
||||
public bool WasCalled { get; private set; }
|
||||
public string? LastKey { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FakeCacheService"/> test double, supplying a newly created <see cref="FakeLockManagerService"/> to the base cache service as its lock-management dependency.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e01af03 body=4448e1d -->
|
||||
public FakeCacheService() : base(new FakeLockManagerService())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stub implementation of <see cref="ICacheService.GetOrSetObjectAsync{T}"/> that records the invocation and the supplied key without performing any caching, and returns the value produced by <paramref name="factory"/>.
|
||||
/// </summary>
|
||||
/// <param name="key">The cache key under which the value would be stored; recorded for later verification.</param>
|
||||
/// <param name="factory">The <see cref="Func{Task{T}}"/> invoked to produce the value returned by this method.</param>
|
||||
/// <param name="ttl">Optional time-to-live for the cache entry; ignored by this implementation.</param>
|
||||
/// <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 -->
|
||||
Task<T> ICacheService.GetOrSetObjectAsync<T>(
|
||||
string key,
|
||||
Func<Task<T>> factory,
|
||||
@@ -138,6 +159,17 @@ public class FakeCacheService : CacheService, ICacheService
|
||||
return factory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves an object from the cache for the given <paramref name="groupedField"/> and <paramref name="patientId"/>, or produces it via <paramref name="factory"/> when no cached entry exists. This implementation unconditionally invokes <paramref name="factory"/> and records the call by setting <see cref="WasCalled"/> to <c>true</c>, ignoring any cached value and the <paramref name="ttl"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the object being retrieved or created.</typeparam>
|
||||
/// <param name="groupedField">The grouped field used as part of the cache lookup key.</param>
|
||||
/// <param name="patientId">The patient identifier used as part of the cache lookup key.</param>
|
||||
/// <param name="factory">The asynchronous factory invoked to produce the value when no cached entry is available.</param>
|
||||
/// <param name="ttl">An optional time-to-live for the cached entry. Not used by this implementation.</param>
|
||||
/// <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 -->
|
||||
Task<T> ICacheService.GetOrSetObjectAsync<T>(
|
||||
GroupedField groupedField,
|
||||
ObjectId patientId,
|
||||
@@ -186,6 +218,10 @@ public class FakeNoCacheService : NoCacheService, ICacheService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Represents a test fixture that exercises the <see cref="CacheDispatcher"/> to validate its expected runtime behavior.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e92eb06 -->
|
||||
[TestFixture]
|
||||
public class CacheDispatcherTest
|
||||
{
|
||||
@@ -216,6 +252,10 @@ public class CacheDispatcherTest
|
||||
|
||||
#region TC-23
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that GetOrSetObjectAsync uses the Redis service when the patients cache mode is configured as <see cref="CacheEnum.Mode.Redis"/>, and does not fall back to the memory or no-op cache services.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3f07bc5 body=9d2c439 -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_UsesRedisService_WhenPatientsModeIsRedis()
|
||||
{
|
||||
@@ -238,6 +278,10 @@ public class CacheDispatcherTest
|
||||
#endregion
|
||||
|
||||
#region TC-24
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CacheDispatcher.GetOrSetObjectAsync{T}"/> delegates to the in-memory cache service when <see cref="CacheSettings.Appointments"/> is set to <see cref="CacheEnum.Mode.Cache"/>, forwarding the supplied key and ensuring that neither the Redis nor the no-op cache implementations are invoked in this scenario.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=69efd2a body=e0ce152 -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_UsesCacheService_WhenAppointmentsModeIsCache()
|
||||
{
|
||||
@@ -260,6 +304,10 @@ public class CacheDispatcherTest
|
||||
#endregion
|
||||
|
||||
#region TC-25
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CacheDispatcher.GetOrSetObjectAsync"/> delegates to the no-op cache service and skips both the Redis and in-memory cache services when <see cref="CacheSettings.PumpObservations"/> is configured with <see cref="CacheEnum.Mode.None"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c516b35 body=f3aa2f5 -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_UsesNoCacheService_WhenPumpObservationsModeIsNone()
|
||||
{
|
||||
@@ -282,6 +330,13 @@ public class CacheDispatcherTest
|
||||
#endregion
|
||||
|
||||
#region TC-26
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="GetOrSetObjectAsync{T}(string, Func{Task{T}})"/> falls back to the InMemory cache service
|
||||
/// when the provided cache key has an unrecognized prefix, ensuring that unknown keys are still served by the default
|
||||
/// cache implementation rather than the <see cref="IRedisCacheService"/> or <see cref="INoCacheService"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> that completes when the fallback behavior has been validated through the assertions.</returns>
|
||||
/// <!-- aidoc:v1 sig=b24df70 body=15e546d -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_UsesCacheService_WhenKeyIsUnrecognized()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,13 @@ namespace adas_core.Test.Services;
|
||||
using adas_core.Application.Services.Caching;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
/// <summary>
|
||||
/// Provides a test fixture containing unit tests for the CacheService class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The <see cref="NUnit.Framework.TestFixtureAttribute"/> indicates that this class groups related test methods executed by the NUnit testing framework.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=90bb100 -->
|
||||
[TestFixture]
|
||||
public class CacheServiceTest
|
||||
{
|
||||
@@ -21,6 +28,10 @@ public class CacheServiceTest
|
||||
_svc = new CacheService(lockMgr);
|
||||
}
|
||||
#region TC-31
|
||||
/// <summary>
|
||||
/// Verifies that GetOrSetObjectAsync returns the previously cached value for a key that already exists in the cache and does not invoke the factory delegate.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=57477a5 body=20c4a7a -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_ReturnsCachedValue_AndDoesNotInvokeFactory_WhenKeyAlreadyExists()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a test fixture that contains unit tests for the <see cref="CameraService"/> class.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a7f21ae -->
|
||||
[TestFixture]
|
||||
internal class CameraServiceTest
|
||||
{
|
||||
|
||||
@@ -16,6 +16,10 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides unit tests for the <see cref="ConfigObservationService"/> class.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b67849b -->
|
||||
[TestFixture]
|
||||
public class ConfigObservationServiceTest
|
||||
{
|
||||
|
||||
@@ -14,6 +14,13 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a test fixture containing unit tests for the <see cref="ConfigPumpsService"/> class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Marked with the NUnit <see cref="TestFixtureAttribute"/> to group and execute the test methods that validate the behavior of <see cref="ConfigPumpsService"/>.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=9b5acf0 -->
|
||||
[TestFixture]
|
||||
public class ConfigPumpsServiceTest
|
||||
{
|
||||
|
||||
@@ -10,6 +10,10 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides unit tests for the <see cref="ConfigUnitsService"/> class.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9068864 -->
|
||||
[TestFixture]
|
||||
public class ConfigUnitsServiceTest
|
||||
{
|
||||
|
||||
@@ -14,6 +14,10 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Defines a test fixture containing unit tests that verify the behavior of the DiagnosisService.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bc1cd44 -->
|
||||
[TestFixture]
|
||||
public class DiagnosisServiceTest
|
||||
{
|
||||
@@ -213,6 +217,10 @@ public class DiagnosisServiceTest
|
||||
_diagnosisRepositoryMock.Verify(d => d.InsertOneAsync(It.IsAny<PatientDiagnosis>()), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="DiagnosisService.SaveRequest"/> does not insert a <see cref="PatientDiagnosis"/> when the supplied <see cref="ApiRequest"/> does not represent diagnosis code settings.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9cdb26c body=11b0c14 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_Not_DiagnosisCodeSettings_Return_not_insert()
|
||||
{
|
||||
|
||||
@@ -15,6 +15,13 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a NUnit test fixture that exercises the behavior of the DisplayService class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Marked with <see cref="TestFixtureAttribute"/> so the NUnit test runner can discover and execute the contained test methods.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=cb14af2 -->
|
||||
[TestFixture]
|
||||
public class DisplayServiceTest
|
||||
{
|
||||
@@ -144,6 +151,12 @@ public class DisplayServiceTest
|
||||
// GetAllByUser - Admin case
|
||||
// -----------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="DisplayService.GetAllByUser"/> returns all <see cref="Display"/> objects
|
||||
/// associated with the units the user has authorization over when the user holds the
|
||||
/// <see cref="PermissionEnum.RolesType.AuthAdmin"/> role.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f3916bd body=50fd0aa -->
|
||||
[Test]
|
||||
public async Task GetAllByUser_ShouldReturnDisplays_WhenAdmin()
|
||||
{
|
||||
|
||||
@@ -12,6 +12,10 @@ using static adas_core.Domain.Enums.GroupedObservationEnum;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a NUnit test fixture that verifies the behavior of <see cref="GroupedObservationService"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bf08b6e -->
|
||||
[TestFixture]
|
||||
public class GroupedObservationServiceTest
|
||||
{
|
||||
|
||||
@@ -9,6 +9,13 @@ using Moq;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Test fixture that contains unit tests for HistoricalConfigChangesService.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Tests in this fixture are decorated with the NonParallelizable attribute and must not execute concurrently with other tests.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=ae94572 -->
|
||||
[TestFixture]
|
||||
[NonParallelizable]
|
||||
internal class HistoricalConfigChangesServiceTest
|
||||
|
||||
@@ -4,6 +4,12 @@ using adas_core.Application.Services.Caching;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// NUnit test fixture that exercises the behavior of the in-memory lock provider.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The <see cref="TestFixtureAttribute"/> attribute marks this class as a container of related test cases.</remarks>
|
||||
/// <!-- aidoc:v1 sig=92f2274 -->
|
||||
[TestFixture]
|
||||
public class InMemoryLockProviderTest
|
||||
{
|
||||
|
||||
@@ -12,6 +12,13 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a NUnit test fixture for validating the behavior of LightBeaconService.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Marked with the <see cref="TestFixtureAttribute"/> attribute, this class groups together unit tests targeting LightBeaconService.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=b588273 -->
|
||||
[TestFixture]
|
||||
public class LightBeaconServiceTest
|
||||
{
|
||||
|
||||
@@ -13,6 +13,10 @@ using Moq;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides unit tests for the <see cref="MasterListService"/> class, exercising its behavior under the NUnit <see cref="TestFixtureAttribute"/> framework.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a1e1475 -->
|
||||
[TestFixture]
|
||||
public class MasterListServiceTest
|
||||
{
|
||||
|
||||
@@ -14,9 +14,17 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="MedicineService"/> class, verifying its behavior and contracts.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6e8ca9d -->
|
||||
[TestFixture]
|
||||
public class MedicineServiceTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the test dependencies for <see cref="MedicineService"/> unit tests by creating mocks for <see cref="IMedicineRepository"/>, <see cref="ITreatmentService"/>, and <see cref="ILogger{MedicineService}"/>, then constructing the service under test with the required collaborators.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=c01c921 -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -55,6 +63,11 @@ public class MedicineServiceTest
|
||||
//private static readonly DateTime now = DateTime.Now;
|
||||
private static readonly ObjectId PatientId = ObjectId.GenerateNewId();
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="MedicineService.GetMedicinesOfTreatments"/> returns an empty result (count of 0) when <see cref="IMedicineRepository.GetMedicineByCodeOrNote"/> yields no <see cref="Medicine"/> items for the supplied <see cref="PatientTreatment"/> entries.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException">Thrown when the local <see cref="List{PatientTreatment}"/> collection is null.</exception>
|
||||
/// <!-- aidoc:v1 sig=6587029 body=89ace4d -->
|
||||
[Test]
|
||||
public async Task GetMedicinesOfTreatments_Null_Medicine_Return_0()
|
||||
{
|
||||
@@ -71,6 +84,11 @@ public class MedicineServiceTest
|
||||
Assert.That(result.Count(), EqualTo(0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="MedicineService.GetMedicinesOfTreatments"/> returns medicines when the supplied
|
||||
/// <see cref="List{PatientTreatment}"/> contains codes matching medicines registered in the repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9b6ab1e body=dfdcc25 -->
|
||||
[Test]
|
||||
public async Task GetMedicinesOfTreatments_Medicines_Return_Medicines()
|
||||
{
|
||||
@@ -117,6 +135,10 @@ public class MedicineServiceTest
|
||||
Assert.That(result.Count(), GreaterThan(0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that <see cref="MedicineService.GetMedicinesOfTreatments"/> returns medicines for a <see cref="PatientTreatment"/> when the medicine repository returns no results for <see cref="MedicineRepository.GetMedicineByCodeOrNote"/>, verifying that the returned medicines contain the identifier and text extracted from <see cref="PatientTreatment.RequestedGiveCodes"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1cd9fc2 body=15ec2c4 -->
|
||||
[Test]
|
||||
public async Task GetMedicinesOfTreatments_Not_Get_Medicines_Return_Note_Medicines()
|
||||
{
|
||||
@@ -152,6 +174,10 @@ public class MedicineServiceTest
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="MedicineService.GetMedicinesOfTreatments"/> falls back to constructing medicines from the <see cref="PatientTreatment.RequestedGiveCodes"/> text when the medicine repository returns no medicines matching the requested codes.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2beba14 body=6e04063 -->
|
||||
[Test]
|
||||
public async Task GetMedicinesOfTreatments_Not_Get_Medicines_Not_Code_identifier_Return_Note_Medicines()
|
||||
{
|
||||
@@ -188,6 +214,10 @@ public class MedicineServiceTest
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="MedicineService.GetMedicinesOfTreatments"/> returns an NPT <see cref="Medicine"/> with type <see cref="MedicineEnum.Types.ParenteralNutrition"/> when the <see cref="PatientTreatment"/> notes contain the "NPT" formularybaseformulation comment.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=186f001 body=182af67 -->
|
||||
[Test]
|
||||
public async Task CalculateParentalNutritionMedicine_Notes_NPT_Return_NPT_Medicine()
|
||||
{
|
||||
@@ -226,6 +256,10 @@ public class MedicineServiceTest
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientTreatment"/> includes notes indicating "NPT" parenteral nutrition and a lipid formulation comment, <see cref="MedicineService.GetMedicinesOfTreatments"/> resolves the treatment into a <see cref="Medicine"/> named "NPT" of type <see cref="MedicineEnum.Types.ParenteralNutritionLipids"/> with no associated code, even when <see cref="IMedicineRepository.GetMedicineByCodeOrNote"/> returns an empty list.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bfdb93a body=11a42b3 -->
|
||||
[Test]
|
||||
public async Task CalculateParentalNutritionMedicine_Notes_NPTL_Return_NPTL_Medicine()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,10 @@ using adas_core.Application.Services.Caching;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Test fixture that validates the behavior of the NoCacheService, ensuring its operations function correctly in a non-caching context.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d79267a -->
|
||||
[TestFixture]
|
||||
public class NoCacheServiceTest
|
||||
{
|
||||
@@ -19,6 +23,11 @@ public class NoCacheServiceTest
|
||||
|
||||
#region TC-27
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the no-cache implementation of <see cref="GetOrSetObjectAsync"/> always invokes the supplied factory delegate
|
||||
/// and never returns a previously cached value, even when called repeatedly with the same key.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0ade665 body=93b4d4c -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_AlwaysCallsFactory_NeverUsesCache()
|
||||
{
|
||||
@@ -45,6 +54,10 @@ public class NoCacheServiceTest
|
||||
Assert.That(result2, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <c>GetOrSetValueAsync</c> invokes the supplied factory delegate once for every unique key passed in, ensuring that the no-cache implementation does not deduplicate or short-circuit calls based on key uniqueness.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=7b6a45d body=15c5c5c -->
|
||||
[Test]
|
||||
public async Task GetOrSetObjectAsync_CallsFactory_ForEachUniqueKey()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,10 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a NUnit test fixture that verifies the behavior of <see cref="ObservationService"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=195961f -->
|
||||
[TestFixture]
|
||||
public class ObservationServiceTest
|
||||
{
|
||||
@@ -159,6 +163,10 @@ public class ObservationServiceTest
|
||||
private static readonly DateTime Now = DateTime.Now;
|
||||
private static readonly ObjectId PatientId = ObjectId.GenerateNewId();
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when an <see cref="ApiRequest"/> contains allergy observations stating that the patient has no known allergies, the observation service does not insert a new <see cref="PatientObservation"/> named "AllergiesObs" for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6c516f0 body=db4def1 -->
|
||||
[Test]
|
||||
public async Task ProcessAllergiesObservation__apiRequest_No_Allergies_Return_Nothing()
|
||||
{
|
||||
@@ -229,6 +237,12 @@ public class ObservationServiceTest
|
||||
)), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the observation processing pipeline correctly handles an <see cref="ApiRequest"/> containing a latex allergy entry,
|
||||
/// ensuring that the mapped <see cref="PatientObservation"/> with its <see cref="PatientAllergiesValue"/> list is persisted via the
|
||||
/// repository's <c>InsertOneAsync</c> call after being resolved through the patient, configuration, and unit services.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=28d5b94 body=563ca14 -->
|
||||
[Test]
|
||||
public async Task ProcessAllergiesObservation_apiRequest_Allergies_Latex_Return_AllergiesObs_Latex()
|
||||
{
|
||||
@@ -328,6 +342,10 @@ public class ObservationServiceTest
|
||||
_observationRepository.Verify(o => o.InsertOneAsync(expectedObs));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="ObservationService.SaveRequest"/> correctly handles an <see cref="ApiRequest"/> of type "ORU_R01" containing allergy-related <see cref="PatientObservation"/> entries, consolidating them into a single <see cref="PatientObservation"/> whose value groups the allergies by type with their allergen and notes, and that the resulting observation is persisted via <see cref="ObservationRepository.InsertOneAsync"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=60d4186 body=38528af -->
|
||||
[Test]
|
||||
public async Task ProcessAllergiesObservation_apiRequest_Allergies_Return_AllergiesObs()
|
||||
{
|
||||
@@ -512,6 +530,10 @@ public class ObservationServiceTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <c>SaveRequest</c> processes an <see cref="ApiRequest"/> of type "ORU_R01" carrying drainages-related <see cref="PatientObservation"/> entries (volume, location, type and column height) and persists the resulting <see cref="PatientObservation"/> through the repository insert operation with the mapped <see cref="PatientDrainagesValue"/> collection as its value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=02099ca body=0538544 -->
|
||||
[Test]
|
||||
public async Task ProcessDrainagesObservation_apiRequest_Drainages_Return_DrainagesObs()
|
||||
{
|
||||
@@ -816,6 +838,10 @@ public class ObservationServiceTest
|
||||
)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="ObservationService.SaveRequest"/> processes an <c>ORU_R01</c> message containing a SNOMED-coded intravenous line observation (peripheral epicatheter at the right temporal zone) and inserts a <see cref="PatientObservation"/> carrying a <see cref="PatientIntravenousLinesValue"/> with the expected <see cref="PatientObservation.Code"/>, <see cref="PatientObservation.CodingSystem"/>, <see cref="PatientObservation.Time"/>, <see cref="PatientObservation.MessageTime"/>, <see cref="PatientObservation.PatientId"/>, and <see cref="PatientObservation.Value"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=d3137cf body=16202aa -->
|
||||
[Test]
|
||||
public async Task ProcessIntravenousLinesObservation_Return_PositionObs()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,10 @@ using static NUnit.Framework.Assert;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Serves as the NUnit <see cref="TestFixtureAttribute"/> test class that contains unit tests for <see cref="PatientService"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=bf19488 -->
|
||||
[TestFixture]
|
||||
internal class PatientServiceTest
|
||||
{
|
||||
@@ -1076,6 +1080,10 @@ internal class PatientServiceTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that an ADT_A02 transfer request for an existing patient targeting a non-existent destination bed moves the patient to a virtual Point of Care flagged as Unknown when <see cref="PointOfCareMapping.Required"/> is disabled.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8f58bf8 body=93b818c -->
|
||||
[Test]
|
||||
public async Task ADT_A02_TRANSFER_PATIENT_FROM_EXISTS_BED_TO_NOT_EXISTS_BED_SHOULD_MOVE_TO_VIRTUAL_POC_UNKNOWN()
|
||||
{
|
||||
|
||||
@@ -14,6 +14,13 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Test fixture that exercises the behavior of <see cref="PointOfCareService"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Marked with <see cref="TestFixtureAttribute"/> so that the test runner discovers and executes the contained test methods.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=4b0404e -->
|
||||
[TestFixture]
|
||||
public class PointOfCareServiceTests
|
||||
{
|
||||
@@ -210,6 +217,13 @@ public class PointOfCareServiceTests
|
||||
Assert.That(result, Is.EqualTo(expectedPointOfCareList));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="PointOfCareService.CheckNextAdmission"/> resolves the <see cref="PointOfCare"/> through the cache factory,
|
||||
/// looks up the next <see cref="Admission"/> when <see cref="PointOfCare.AdmissionId"/> is null, assigns it to the PoC,
|
||||
/// transitions the <see cref="StatusEnum.PointOfCare"/> status to Reserved, and invokes <see cref="IPointOfCareRepository.Update"/> exactly once,
|
||||
/// without taking the <c>FindByIdAllConfig</c> code path.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=32ec21f body=2809040 -->
|
||||
[Test]
|
||||
public void CheckNextAdmission_ValidPatientLocation_UpdatesPoCStatus_AndCallsUpdate()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,10 @@ using Moq;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a test fixture that validates the behavior of the <see cref="PublisherService"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=be0a4eb -->
|
||||
[TestFixture]
|
||||
public class PublisherServiceTest
|
||||
{
|
||||
|
||||
@@ -17,6 +17,13 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a test fixture for verifying the behavior of the PumpService.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is decorated with the TestFixture attribute and hosts the unit tests for the PumpService.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=e17ee05 -->
|
||||
[TestFixture]
|
||||
public class PumpServiceTest
|
||||
{
|
||||
@@ -293,6 +300,10 @@ public class PumpServiceTest
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="SaveRequest"/> falls back to <see cref="ApiRequest.Location"/> when the patient cannot be resolved from the API request, broadcasts the resulting <see cref="PumpState"/> to subscribers matching that location, and skips <see cref="OperationType.PumpAlarm"/> messages when no active alarms exist.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b11b322 body=c2ffc92 -->
|
||||
[Test]
|
||||
public async Task SaveRequest_WithSubscribers_UsesReqLocation_AndSendsBroadcast()
|
||||
{
|
||||
|
||||
@@ -11,6 +11,10 @@ using Moq;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a test fixture containing unit tests for the <see cref="RecordingAlertService"/> class.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=510464c -->
|
||||
[TestFixture]
|
||||
public class RecordingAlertServiceTest
|
||||
{
|
||||
|
||||
@@ -16,6 +16,13 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Acts as a NUnit test fixture that validates the behavior of the <see cref="RecordingService"/> class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Marked with <see cref="TestFixtureAttribute"/>, this class groups the unit tests that exercise <see cref="RecordingService"/>.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=967604d -->
|
||||
[TestFixture]
|
||||
public class RecordingServiceTest
|
||||
{
|
||||
|
||||
@@ -5,6 +5,13 @@ using StackExchange.Redis;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a test fixture that contains unit tests for the RedisLockProvider class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Decorated with the TestFixture attribute so that NUnit-compatible test runners can discover and execute its test methods.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=cb004e0 -->
|
||||
[TestFixture]
|
||||
public class RedisLockProviderTest
|
||||
{
|
||||
|
||||
@@ -9,6 +9,10 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an NUnit <see cref="TestFixtureAttribute"/> containing unit tests that exercise the behavior of the Redis service.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=920ae32 -->
|
||||
[TestFixture]
|
||||
public class RedisServiceTest
|
||||
{
|
||||
|
||||
@@ -13,6 +13,10 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a NUnit test fixture that contains the unit tests for the RelayService class.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8ce82ad -->
|
||||
[TestFixture]
|
||||
public class RelayServiceTest
|
||||
{
|
||||
@@ -176,6 +180,10 @@ public class RelayServiceTest
|
||||
Assert.That(result, Is.EqualTo(RelayEnum.Status.On));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the relay status check returns <see cref="RelayEnum.Status.Off"/> when the mocked HTTP response indicates the relay is off, after invoking the power-off operation on the supplied <see cref="Relay"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ba0668b body=434ffc5 -->
|
||||
[Test]
|
||||
public async Task CheckRelayStatus_Return_Off()
|
||||
{
|
||||
|
||||
@@ -16,9 +16,26 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests that verify the behavior of the <see cref="SchedulerService"/> class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Marked as a test fixture so that the contained test methods are discovered and executed by the test runner.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=97a1147 -->
|
||||
[TestFixture]
|
||||
public class SchedulerServiceTest
|
||||
{
|
||||
/// <summary>
|
||||
/// One-time setup that initializes mocked services, lazy wrappers, and test data
|
||||
/// required to exercise <see cref="SchedulerService"/> along with the Quartz-based
|
||||
/// news and expiration jobs (<see cref="CalculateNewsJob"/>, <see cref="CheckExpiredAlertsJob"/>,
|
||||
/// <see cref="CheckExpiredObservationsJob"/>). It configures <see cref="IConfigObservationService"/> and
|
||||
/// <see cref="IObservationService"/> behaviors to match observations by name and patient, and the
|
||||
/// <see cref="IPatientService"/> to return the predefined patient list from
|
||||
/// <see cref="IPatientService.FindInActivePoC"/>, then starts the underlying scheduler.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=518646b body=ec531a6 -->
|
||||
[OneTimeSetUp]
|
||||
public async Task SetUp()
|
||||
{
|
||||
@@ -267,6 +284,10 @@ public class SchedulerServiceTest
|
||||
|
||||
|
||||
//[TearDown]
|
||||
/// <summary>
|
||||
/// Stops the Quartz.NET scheduler engine after all tests in the fixture have run. Uses the null-conditional operator so the call is safely skipped when the scheduler was never initialized.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3273a4f body=5bdc9c3 -->
|
||||
[OneTimeTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
|
||||
@@ -7,6 +7,10 @@ using Moq;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a test fixture for unit testing the SendAlertService class.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=405aa53 -->
|
||||
[TestFixture]
|
||||
public class SendAlertServiceTest
|
||||
{
|
||||
|
||||
@@ -7,6 +7,10 @@ using ServiceConfigService = adas_core.Application.Services.ServiceConfigService
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Test fixture for the ServiceConfigService, containing its related unit tests.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6171c91 -->
|
||||
[TestFixture]
|
||||
public class ServiceConfigServiceTest
|
||||
{
|
||||
|
||||
@@ -13,6 +13,10 @@ using static NUnit.Framework.Assert;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Acts as the NUnit test fixture for the TreatmentService, housing the unit tests that verify its behavior.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ea3a14e -->
|
||||
[TestFixture]
|
||||
public class TreatmentServiceTest
|
||||
{
|
||||
|
||||
@@ -9,6 +9,10 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace adas_core.Test.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a <see cref="TestFixtureAttribute"/> that validates the behavior of <see cref="CacheKeyClassifier"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=417f7b7 -->
|
||||
[TestFixture]
|
||||
public class CacheKeyClassifierTest
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user