rama creada apartir de master en j
This commit is contained in:
@@ -12,47 +12,52 @@ namespace adas_core.Test.Repositories;
|
||||
[Category("Integration")]
|
||||
public class DiagnosisArchiveRepositoryTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the test fixture by creating sample patient diagnosis records, resetting the
|
||||
/// archive collection in the integration database, and configuring the diagnosis archive
|
||||
/// repository used by the test suite.
|
||||
/// </summary>
|
||||
[OneTimeSetUp]
|
||||
public async Task Init()
|
||||
{
|
||||
_optionsApiSettings = Options.Create(_apiSettings);
|
||||
|
||||
var patientDiagnosis1 = new PatientDiagnosis
|
||||
public async Task Init()
|
||||
{
|
||||
Id = Id,
|
||||
PatientId = PatientId,
|
||||
Time = Now.AddDays(-1),
|
||||
Code = "code1",
|
||||
DiagnosisSystem = "diagnosisSystem"
|
||||
};
|
||||
|
||||
var patientDiagnosis2 = new PatientDiagnosis
|
||||
{
|
||||
Id = ObjectId.GenerateNewId(),
|
||||
PatientId = PatientId,
|
||||
Time = Now.AddDays(-2),
|
||||
Code = "code2",
|
||||
DiagnosisSystem = "diagnosisSystem"
|
||||
};
|
||||
|
||||
var patientDiagnosis3 = new PatientDiagnosis
|
||||
{
|
||||
Id = ObjectId.GenerateNewId(),
|
||||
PatientId = PatientId,
|
||||
Time = Now.AddDays(-3),
|
||||
Code = "code3",
|
||||
DiagnosisSystem = "diagnosisSystem"
|
||||
};
|
||||
|
||||
await IntegrationDb.Database.DropCollectionAsync("archive_patients_diagnosis");
|
||||
await IntegrationDb.Database.CreateCollectionAsync("archive_patients_diagnosis");
|
||||
|
||||
_repository = new DiagnosisArchiveRepository(_optionsApiSettings, IntegrationDb.Database);
|
||||
|
||||
await _repository.InsertOneAsync(patientDiagnosis1);
|
||||
await _repository.InsertOneAsync(patientDiagnosis2);
|
||||
await _repository.InsertOneAsync(patientDiagnosis3);
|
||||
}
|
||||
_optionsApiSettings = Options.Create(_apiSettings);
|
||||
|
||||
var patientDiagnosis1 = new PatientDiagnosis
|
||||
{
|
||||
Id = Id,
|
||||
PatientId = PatientId,
|
||||
Time = Now.AddDays(-1),
|
||||
Code = "code1",
|
||||
DiagnosisSystem = "diagnosisSystem"
|
||||
};
|
||||
|
||||
var patientDiagnosis2 = new PatientDiagnosis
|
||||
{
|
||||
Id = ObjectId.GenerateNewId(),
|
||||
PatientId = PatientId,
|
||||
Time = Now.AddDays(-2),
|
||||
Code = "code2",
|
||||
DiagnosisSystem = "diagnosisSystem"
|
||||
};
|
||||
|
||||
var patientDiagnosis3 = new PatientDiagnosis
|
||||
{
|
||||
Id = ObjectId.GenerateNewId(),
|
||||
PatientId = PatientId,
|
||||
Time = Now.AddDays(-3),
|
||||
Code = "code3",
|
||||
DiagnosisSystem = "diagnosisSystem"
|
||||
};
|
||||
|
||||
await IntegrationDb.Database.DropCollectionAsync("archive_patients_diagnosis");
|
||||
await IntegrationDb.Database.CreateCollectionAsync("archive_patients_diagnosis");
|
||||
|
||||
_repository = new DiagnosisArchiveRepository(_optionsApiSettings, IntegrationDb.Database);
|
||||
|
||||
await _repository.InsertOneAsync(patientDiagnosis1);
|
||||
await _repository.InsertOneAsync(patientDiagnosis2);
|
||||
await _repository.InsertOneAsync(patientDiagnosis3);
|
||||
}
|
||||
|
||||
private DiagnosisArchiveRepository _repository;
|
||||
|
||||
@@ -68,19 +73,24 @@ public class DiagnosisArchiveRepositoryTest
|
||||
private static readonly ObjectId Id = ObjectId.GenerateNewId();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the repository's <c>DeleteBeforeDate</c> operation correctly removes all records
|
||||
/// for a given patient that were created before the specified cutoff date, while preserving records
|
||||
/// created on or after that date.
|
||||
/// </summary>
|
||||
[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.AddDays(-1));
|
||||
|
||||
var resultDelete = await _repository.Collection.FindAsync(p => p.PatientId == PatientId);
|
||||
|
||||
Assert.That(resultDelete, Is.Not.Null);
|
||||
Assert.That(resultDelete.ToList(), Has.Count.EqualTo(1));
|
||||
}
|
||||
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.AddDays(-1));
|
||||
|
||||
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