rama creada apartir de master en j
This commit is contained in:
@@ -323,268 +323,294 @@ public class SchedulerServiceTest
|
||||
private static readonly ObjectId PatientId = ObjectId.GenerateNewId();
|
||||
private static readonly ObjectId PatientId2 = ObjectId.GenerateNewId();
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="CheckInactivePatientsJob"/> is executed when its Quartz.NET trigger fires,
|
||||
/// ensuring the scheduled job invokes the patient discharge process for inactive patients at the configured interval.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void CheckInactivePatientsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
var checkInactivePatientSchedulerIntervalHours = 12;
|
||||
|
||||
// Arrange
|
||||
var checkInactivePatientsJob = JobBuilder.Create<CheckInactivePatientsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var checkInactivePatientsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(checkInactivePatientSchedulerIntervalHours)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
|
||||
_patientServiceMock?.Setup(p => p.DischargeInactivePatients(_sinceDate, _sinceDischargeTimeToArchive));
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(checkInactivePatientsJob, checkInactivePatientsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
|
||||
|
||||
_patientServiceMock?.Verify(p => p.DischargeInactivePatients(It.IsAny<DateTime>(), It.IsAny<int>()),
|
||||
Times.AtLeastOnce());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void CheckActiveTreatmentsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
var patient = new Patient
|
||||
public void CheckInactivePatientsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
PatientId = PatientId.ToString(),
|
||||
UnitString = "NEONATAL",
|
||||
Bed = "CINA02",
|
||||
PatientNumber = "123456",
|
||||
Person = new Person
|
||||
{
|
||||
FirstName = "Jose",
|
||||
LastName = "Luis",
|
||||
BirthDate = new DateTime(),
|
||||
Gender = PatientEnum.Gender.Male
|
||||
}
|
||||
};
|
||||
var checkInactivePatientSchedulerIntervalHours = 12;
|
||||
|
||||
// Arrange
|
||||
var checkInactivePatientsJob = JobBuilder.Create<CheckInactivePatientsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var checkInactivePatientsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(checkInactivePatientSchedulerIntervalHours)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
|
||||
_patientServiceMock?.Setup(p => p.DischargeInactivePatients(_sinceDate, _sinceDischargeTimeToArchive));
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(checkInactivePatientsJob, checkInactivePatientsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
|
||||
|
||||
_patientServiceMock?.Verify(p => p.DischargeInactivePatients(It.IsAny<DateTime>(), It.IsAny<int>()),
|
||||
Times.AtLeastOnce());
|
||||
}
|
||||
|
||||
const int checkActiveTreatmentsSchedulerIntervalMinutes = 10;
|
||||
|
||||
var treatmentsJob = JobBuilder.Create<CheckActiveTreatmentsJob>()
|
||||
.Build();
|
||||
|
||||
// Trigger the job to run now, and then repeat every 10 seconds
|
||||
var treatmentsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInMinutes(checkActiveTreatmentsSchedulerIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
_patientServiceMock?.Setup(p => p.FindAll(It.IsAny<bool>())).ReturnsAsync([patient]);
|
||||
|
||||
// Create a mock of the singleton class subscribers
|
||||
var mockSingleton = new Mock<ICalculatedObservationsService>();
|
||||
|
||||
// Set up the mock object to return a specific value when a method is called
|
||||
var patientTreatmentList = new List<PatientTreatment?>
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="CheckActiveTreatmentsJob"/> is executed by the Quartz scheduler
|
||||
/// when triggered, and that the medicine service is invoked exactly once to retrieve medicines
|
||||
/// for the active treatments of the mocked patients.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void CheckActiveTreatmentsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
new()
|
||||
var patient = new Patient
|
||||
{
|
||||
Id = ObjectId.GenerateNewId(),
|
||||
PatientId = PatientId,
|
||||
OrderControl = OrderControlType.Nw,
|
||||
PlacerOrder = new Entity { EntityIdentifier = "3690", NamespaceId = "CareVue" },
|
||||
FillerOrder = new Entity { EntityIdentifier = "3690", NamespaceId = "CareVue" },
|
||||
OrderStatus = "A",
|
||||
OrderTime = Now,
|
||||
Notes = [],
|
||||
Routes = []
|
||||
}
|
||||
};
|
||||
|
||||
mockSingleton.Setup(x => x.GetActiveTreatmentsByPatient(PatientId)).ReturnsAsync(patientTreatmentList);
|
||||
|
||||
|
||||
_medicineServiceMock?.Setup(m => m.GetMedicinesOfTreatments(It.IsAny<List<PatientTreatment>>()))
|
||||
.ReturnsAsync(new List<Medicine>());
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(treatmentsJob, treatmentsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(10));
|
||||
|
||||
_medicineServiceMock?.Verify(x => x.GetMedicinesOfTreatments(It.IsAny<IEnumerable<PatientTreatment>>()),
|
||||
Times.Once());
|
||||
}
|
||||
PatientId = PatientId.ToString(),
|
||||
UnitString = "NEONATAL",
|
||||
Bed = "CINA02",
|
||||
PatientNumber = "123456",
|
||||
Person = new Person
|
||||
{
|
||||
FirstName = "Jose",
|
||||
LastName = "Luis",
|
||||
BirthDate = new DateTime(),
|
||||
Gender = PatientEnum.Gender.Male
|
||||
}
|
||||
};
|
||||
|
||||
const int checkActiveTreatmentsSchedulerIntervalMinutes = 10;
|
||||
|
||||
var treatmentsJob = JobBuilder.Create<CheckActiveTreatmentsJob>()
|
||||
.Build();
|
||||
|
||||
// Trigger the job to run now, and then repeat every 10 seconds
|
||||
var treatmentsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInMinutes(checkActiveTreatmentsSchedulerIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
_patientServiceMock?.Setup(p => p.FindAll(It.IsAny<bool>())).ReturnsAsync([patient]);
|
||||
|
||||
// Create a mock of the singleton class subscribers
|
||||
var mockSingleton = new Mock<ICalculatedObservationsService>();
|
||||
|
||||
// Set up the mock object to return a specific value when a method is called
|
||||
var patientTreatmentList = new List<PatientTreatment?>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = ObjectId.GenerateNewId(),
|
||||
PatientId = PatientId,
|
||||
OrderControl = OrderControlType.Nw,
|
||||
PlacerOrder = new Entity { EntityIdentifier = "3690", NamespaceId = "CareVue" },
|
||||
FillerOrder = new Entity { EntityIdentifier = "3690", NamespaceId = "CareVue" },
|
||||
OrderStatus = "A",
|
||||
OrderTime = Now,
|
||||
Notes = [],
|
||||
Routes = []
|
||||
}
|
||||
};
|
||||
|
||||
mockSingleton.Setup(x => x.GetActiveTreatmentsByPatient(PatientId)).ReturnsAsync(patientTreatmentList);
|
||||
|
||||
|
||||
_medicineServiceMock?.Setup(m => m.GetMedicinesOfTreatments(It.IsAny<List<PatientTreatment>>()))
|
||||
.ReturnsAsync(new List<Medicine>());
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(treatmentsJob, treatmentsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(10));
|
||||
|
||||
_medicineServiceMock?.Verify(x => x.GetMedicinesOfTreatments(It.IsAny<IEnumerable<PatientTreatment>>()),
|
||||
Times.Once());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="CheckExpiredObservationsJob"/> is executed at least once by the Quartz.NET scheduler when triggered with a recurring schedule.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void CheckExpiredObservationsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
var checkExpiredObservationsIntervalMinutes = 3;
|
||||
|
||||
// Arrange
|
||||
var checkExpiredObservationsJob = JobBuilder.Create<CheckExpiredObservationsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var checkExpiredObservationsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(checkExpiredObservationsIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(checkExpiredObservationsJob, checkExpiredObservationsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
|
||||
|
||||
_observationServiceMock?.Verify(p => p.ExpireObservationsAndRecalculateAsync(), Times.AtLeastOnce());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void CheckExpiredAlertsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
var checkExpiredAlertsIntervalMinutes = 3;
|
||||
|
||||
// Arrange
|
||||
var checkExpiredAlertsJob = JobBuilder.Create<CheckExpiredAlertsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var checkExpiredAlertsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(checkExpiredAlertsIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(checkExpiredAlertsJob, checkExpiredAlertsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
|
||||
|
||||
_observationServiceMock?.Verify(p => p.ExpireAlertsAndPowerOffAsync(), Times.AtLeastOnce());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetProvidersObservationsJob_ShouldExecuteOnTrigger_Result_GetType_null()
|
||||
{
|
||||
var getProviderObservationsIntervalMinutes = 5;
|
||||
|
||||
var patient = new Patient
|
||||
public void CheckExpiredObservationsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
PatientId = PatientId.ToString(),
|
||||
UnitString = "NEONATAL",
|
||||
Bed = "CINA02",
|
||||
PatientNumber = "123456",
|
||||
Person = new Person
|
||||
var checkExpiredObservationsIntervalMinutes = 3;
|
||||
|
||||
// Arrange
|
||||
var checkExpiredObservationsJob = JobBuilder.Create<CheckExpiredObservationsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var checkExpiredObservationsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(checkExpiredObservationsIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(checkExpiredObservationsJob, checkExpiredObservationsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
|
||||
|
||||
_observationServiceMock?.Verify(p => p.ExpireObservationsAndRecalculateAsync(), Times.AtLeastOnce());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="CheckExpiredAlertsJob"/> is executed when triggered by the Quartz.NET scheduler, ensuring that the <c>ExpireAlertsAndPowerOffAsync</c> method on the observation service is invoked at least once.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void CheckExpiredAlertsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
var checkExpiredAlertsIntervalMinutes = 3;
|
||||
|
||||
// Arrange
|
||||
var checkExpiredAlertsJob = JobBuilder.Create<CheckExpiredAlertsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var checkExpiredAlertsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(checkExpiredAlertsIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(checkExpiredAlertsJob, checkExpiredAlertsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
|
||||
|
||||
_observationServiceMock?.Verify(p => p.ExpireAlertsAndPowerOffAsync(), Times.AtLeastOnce());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="GetProvidersObservationsJob"/> Quartz.NET job, when triggered, never invokes
|
||||
/// <c>InsertObservation</c> with a <see cref="PatientObservation"/> whose <c>Name</c> is not "NEWS", ensuring
|
||||
/// that only NEWS observations are considered for persistence during scheduled execution.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void GetProvidersObservationsJob_ShouldExecuteOnTrigger_Result_GetType_null()
|
||||
{
|
||||
var getProviderObservationsIntervalMinutes = 5;
|
||||
|
||||
var patient = new Patient
|
||||
{
|
||||
FirstName = "Jose",
|
||||
LastName = "Luis",
|
||||
BirthDate = new DateTime(),
|
||||
Gender = PatientEnum.Gender.Male
|
||||
}
|
||||
};
|
||||
|
||||
// Arrange
|
||||
var getProvidersObservationsJob = JobBuilder.Create<GetProvidersObservationsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var getProvidersObservationsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(getProviderObservationsIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
_patientServiceMock?.Setup(p => p.FindAll(It.IsAny<bool>())).ReturnsAsync([patient]);
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(getProvidersObservationsJob, getProvidersObservationsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
|
||||
//observationServiceMock.Verify(p => p.InsertObservation(It.IsAny<PatientObservation>(),true,true), Times.AtLeastOnce());
|
||||
_observationServiceMock?.Verify(p => p.InsertObservation(
|
||||
It.Is<PatientObservation>(obs => obs.Name != "NEWS"), true, true), Times.Never());
|
||||
}
|
||||
PatientId = PatientId.ToString(),
|
||||
UnitString = "NEONATAL",
|
||||
Bed = "CINA02",
|
||||
PatientNumber = "123456",
|
||||
Person = new Person
|
||||
{
|
||||
FirstName = "Jose",
|
||||
LastName = "Luis",
|
||||
BirthDate = new DateTime(),
|
||||
Gender = PatientEnum.Gender.Male
|
||||
}
|
||||
};
|
||||
|
||||
// Arrange
|
||||
var getProvidersObservationsJob = JobBuilder.Create<GetProvidersObservationsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var getProvidersObservationsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(getProviderObservationsIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
_patientServiceMock?.Setup(p => p.FindAll(It.IsAny<bool>())).ReturnsAsync([patient]);
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(getProvidersObservationsJob, getProvidersObservationsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
|
||||
//observationServiceMock.Verify(p => p.InsertObservation(It.IsAny<PatientObservation>(),true,true), Times.AtLeastOnce());
|
||||
_observationServiceMock?.Verify(p => p.InsertObservation(
|
||||
It.Is<PatientObservation>(obs => obs.Name != "NEWS"), true, true), Times.Never());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="CalculateNewsJob"/> is executed when triggered by the Quartz.NET scheduler, confirming that the associated <c>InsertObservation</c> call on the observation service is invoked at least once within the allowed execution window.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void CheckCalculateNewsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
var checkExpiredAlertsIntervalMinutes = 3;
|
||||
|
||||
// Arrange
|
||||
var calculateNewsJob = JobBuilder.Create<CalculateNewsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var checkExpiredAlertsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(checkExpiredAlertsIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(calculateNewsJob, checkExpiredAlertsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(6));
|
||||
|
||||
|
||||
_observationServiceMock?.Verify(p => p.InsertObservation(It.IsAny<PatientObservation>(), true, true),
|
||||
Times.AtLeastOnce());
|
||||
}
|
||||
public void CheckCalculateNewsJob_ShouldExecuteOnTrigger()
|
||||
{
|
||||
var checkExpiredAlertsIntervalMinutes = 3;
|
||||
|
||||
// Arrange
|
||||
var calculateNewsJob = JobBuilder.Create<CalculateNewsJob>()
|
||||
.UsingJobData(_jobDataMap)
|
||||
.Build();
|
||||
|
||||
// Crear un disparador personalizado que incremente el contador
|
||||
var checkExpiredAlertsTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInHours(checkExpiredAlertsIntervalMinutes)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
|
||||
// Asociar el trabajo y el desencadenador en el motor de Quartz.NET
|
||||
_scheduler?.ScheduleJob(calculateNewsJob, checkExpiredAlertsTrigger).Wait();
|
||||
|
||||
// Act
|
||||
// Esperar un tiempo suficiente para que el trabajo se ejecute varias veces
|
||||
Thread.Sleep(TimeSpan.FromSeconds(6));
|
||||
|
||||
|
||||
_observationServiceMock?.Verify(p => p.InsertObservation(It.IsAny<PatientObservation>(), true, true),
|
||||
Times.AtLeastOnce());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculateNewsJob.Execute"/> correctly inserts NEWS observations with the expected calculated values (1 and 4) for multiple patients in a single execution.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task CalculateNewsJob_Insert_ObsFull_MultiplePatient_With_Correct_Value()
|
||||
{
|
||||
var job = new CalculateNewsJob();
|
||||
|
||||
// Act
|
||||
await job.Execute(Mock.Of<IJobExecutionContext>());
|
||||
|
||||
// Assert
|
||||
_observationServiceMock?.Verify(
|
||||
service => service.InsertObservation(
|
||||
It.Is<PatientObservation>(obs =>
|
||||
obs.Name == "NEWS" && (int)obs.Value == 1 && obs.PatientId == PatientId),
|
||||
true, true),
|
||||
Times.Once);
|
||||
|
||||
_observationServiceMock?.Verify(
|
||||
service => service.InsertObservation(
|
||||
It.Is<PatientObservation>(obs =>
|
||||
obs.Name == "NEWS" && (int)obs.Value == 4 && obs.PatientId == PatientId2),
|
||||
true, true),
|
||||
Times.Once);
|
||||
}
|
||||
public async Task CalculateNewsJob_Insert_ObsFull_MultiplePatient_With_Correct_Value()
|
||||
{
|
||||
var job = new CalculateNewsJob();
|
||||
|
||||
// Act
|
||||
await job.Execute(Mock.Of<IJobExecutionContext>());
|
||||
|
||||
// Assert
|
||||
_observationServiceMock?.Verify(
|
||||
service => service.InsertObservation(
|
||||
It.Is<PatientObservation>(obs =>
|
||||
obs.Name == "NEWS" && (int)obs.Value == 1 && obs.PatientId == PatientId),
|
||||
true, true),
|
||||
Times.Once);
|
||||
|
||||
_observationServiceMock?.Verify(
|
||||
service => service.InsertObservation(
|
||||
It.Is<PatientObservation>(obs =>
|
||||
obs.Name == "NEWS" && (int)obs.Value == 4 && obs.PatientId == PatientId2),
|
||||
true, true),
|
||||
Times.Once);
|
||||
}
|
||||
//Se deshabilita el mensaje de warning porque lo detecta como no usado y sugiere suprimirlo siendo necesario
|
||||
}
|
||||
Reference in New Issue
Block a user