Creado apartir del commit b888de6c92056de294456f581a56e25e734d4ab7 de develop
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
using adas_core.Domain.Enums;
|
||||
using adas_core.Domain.Models;
|
||||
using adas_core.Domain.Models.AppSettings;
|
||||
using adas_core.Infrastructure.Repositories;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Repositories;
|
||||
|
||||
[TestFixture]
|
||||
[Category("Integration")]
|
||||
public class AppointmentArchiveRepositoryTest
|
||||
{
|
||||
[OneTimeSetUp]
|
||||
public async Task Init()
|
||||
{
|
||||
_optionsApiSettings = Options.Create(_apiSettings);
|
||||
|
||||
var patient = new Person
|
||||
{
|
||||
FirstName = "firstName",
|
||||
SecondName = "secondName",
|
||||
BirthDate = Now.AddYears(-10),
|
||||
Gender = PatientEnum.Gender.Female,
|
||||
Ids = new Dictionary<string, string> { { "MR", "123456" }, { "VN", "654321" } }
|
||||
};
|
||||
|
||||
PatientAppointment testPatientAppointment = new()
|
||||
{
|
||||
PatientId = PatientId,
|
||||
Patient = patient,
|
||||
CreateTime = Now.AddHours(-2),
|
||||
UpdateTime = Now.AddHours(-2)
|
||||
};
|
||||
|
||||
PatientAppointment testPatientAppointment2 = new()
|
||||
{
|
||||
PatientId = PatientId,
|
||||
Patient = patient,
|
||||
CreateTime = Now.AddHours(-3),
|
||||
UpdateTime = Now.AddHours(-3),
|
||||
VisitNumber = "654321",
|
||||
AppointmentReason = "appointmentReason",
|
||||
ResourceGroups =
|
||||
[
|
||||
new PatientAppointmentResourceGroup
|
||||
{
|
||||
Locations = [new PatientLocation("UCI5C", "Box4")]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
await IntegrationDb.Database.DropCollectionAsync("patients_appointments");
|
||||
await IntegrationDb.Database.CreateCollectionAsync("patients_appointments");
|
||||
|
||||
_repository = new AppointmentArchiveRepository(_optionsApiSettings, IntegrationDb.Database);
|
||||
|
||||
await _repository.InsertOneAsync(testPatientAppointment);
|
||||
await _repository.InsertOneAsync(testPatientAppointment2);
|
||||
}
|
||||
|
||||
private AppointmentArchiveRepository _repository;
|
||||
|
||||
private readonly ApiSettings _apiSettings = new()
|
||||
{
|
||||
ArchivePatientsAppointments = "archive_patients_appointments"
|
||||
};
|
||||
|
||||
private IOptions<ApiSettings> _optionsApiSettings;
|
||||
//Mock<ILogger<ObservationRepository>> logger;
|
||||
|
||||
private static readonly DateTime Now = DateTime.Now;
|
||||
private static readonly ObjectId PatientId = ObjectId.GenerateNewId();
|
||||
|
||||
|
||||
[Test]
|
||||
public async Task DeleteBeforeDate()
|
||||
{
|
||||
var result = await _repository.Collection.FindAsync(p => p.PatientId == PatientId);
|
||||
|
||||
Assert.That(result, Is.Not.Null);
|
||||
Assert.That(result.ToList(), Has.Count.GreaterThan(1));
|
||||
|
||||
await _repository.DeleteBeforeDate(Now.AddHours(-2));
|
||||
|
||||
var resultDelete = await _repository.Collection.FindAsync(p => p.PatientId == PatientId);
|
||||
|
||||
Assert.That(resultDelete, Is.Not.Null);
|
||||
Assert.That(resultDelete.ToList(), Has.Count.EqualTo(1));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user