Creado apartir del commit b888de6c92056de294456f581a56e25e734d4ab7 de develop
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
using adas_core.Domain.Models.AppSettings;
|
||||
using adas_core.Domain.Models.MongoModels;
|
||||
using adas_core.Infrastructure.Repositories;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Repositories;
|
||||
|
||||
[TestFixture]
|
||||
[Category("Integration")]
|
||||
public class PoCMappingRepositoryTest
|
||||
{
|
||||
[OneTimeSetUp]
|
||||
public async Task Init()
|
||||
{
|
||||
_optionsApiSettings = Options.Create(_apiSettings);
|
||||
|
||||
var mappingItem1 = new PoCMappingItem
|
||||
{
|
||||
OriginalPoC = "original1",
|
||||
NewPoC = "new1",
|
||||
Beds =
|
||||
[
|
||||
new List<string> { "bed1", "bed 1" },
|
||||
new List<string> { "bed2", "bed 2" },
|
||||
new List<string> { "bed3", "bed 3" },
|
||||
new List<string> { "bed4", "bed 4" },
|
||||
new List<string> { "bed5", "bed 5" },
|
||||
new List<string> { "bed6", "bed 6" },
|
||||
new List<string> { "bed7", "bed 7" },
|
||||
new List<string> { "bed8", "bed 8" },
|
||||
new List<string> { "bed9", "bed 9" },
|
||||
new List<string> { "bed10", "bed 10" },
|
||||
new List<string> { "bed11", "bed 11" }
|
||||
]
|
||||
};
|
||||
|
||||
var pointOfCares = new List<PoCMappingItem> { mappingItem1 };
|
||||
|
||||
var mapping = new PoCMapping
|
||||
{
|
||||
Id = "PV1",
|
||||
PointOfCares = pointOfCares
|
||||
};
|
||||
|
||||
await IntegrationDb.Database.DropCollectionAsync("mappings");
|
||||
await IntegrationDb.Database.CreateCollectionAsync("mappings");
|
||||
|
||||
_repository = new PoCMappingRepository(_optionsApiSettings, IntegrationDb.Database);
|
||||
|
||||
await _repository.InsertOneAsync(mapping);
|
||||
}
|
||||
|
||||
private PoCMappingRepository _repository;
|
||||
|
||||
private readonly ApiSettings _apiSettings = new();
|
||||
|
||||
private IOptions<ApiSettings> _optionsApiSettings;
|
||||
|
||||
|
||||
[Test]
|
||||
public async Task FindByKey_Find_Return_Mapping()
|
||||
{
|
||||
var result = await _repository.FindByKey("PV1");
|
||||
|
||||
Assert.That(result, Is.Not.Null);
|
||||
Assert.That(result!.PointOfCares, Has.Count.GreaterThan(0));
|
||||
Assert.That(result.PointOfCares[0].Beds, Has.Count.GreaterThan(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindByKey_Not_Find_Return_Mapping()
|
||||
{
|
||||
var result = await _repository.FindByKey("PV2");
|
||||
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user