rama creada apartir de master en j
This commit is contained in:
@@ -10,27 +10,30 @@ namespace adas_core.Test.Repositories;
|
||||
[Category("Integration")]
|
||||
public class ConfigUnitsRepositoryTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Performs one-time setup for integration tests by resetting the <c>config_units</c> collection and seeding it with a single <see cref="ConfigUnits"/> document (Id "PV1") containing two empty <see cref="ConfigUnitItem"/> entries, then initializes the <see cref="ConfigUnitsRepository"/> used by the tests.
|
||||
/// </summary>
|
||||
[OneTimeSetUp]
|
||||
public async Task Init()
|
||||
{
|
||||
_optionsApiSettings = Options.Create(_apiSettings);
|
||||
|
||||
var configUnitItem1 = new ConfigUnitItem();
|
||||
var configUnitItem2 = new ConfigUnitItem();
|
||||
|
||||
var configUnits = new ConfigUnits
|
||||
public async Task Init()
|
||||
{
|
||||
Id = "PV1",
|
||||
Items = [configUnitItem1, configUnitItem2]
|
||||
};
|
||||
|
||||
await IntegrationDb.Database.DropCollectionAsync("config_units");
|
||||
await IntegrationDb.Database.CreateCollectionAsync("config_units");
|
||||
|
||||
_repository = new ConfigUnitsRepository(_optionsApiSettings, IntegrationDb.Database);
|
||||
|
||||
await _repository.InsertOneAsync(configUnits);
|
||||
}
|
||||
_optionsApiSettings = Options.Create(_apiSettings);
|
||||
|
||||
var configUnitItem1 = new ConfigUnitItem();
|
||||
var configUnitItem2 = new ConfigUnitItem();
|
||||
|
||||
var configUnits = new ConfigUnits
|
||||
{
|
||||
Id = "PV1",
|
||||
Items = [configUnitItem1, configUnitItem2]
|
||||
};
|
||||
|
||||
await IntegrationDb.Database.DropCollectionAsync("config_units");
|
||||
await IntegrationDb.Database.CreateCollectionAsync("config_units");
|
||||
|
||||
_repository = new ConfigUnitsRepository(_optionsApiSettings, IntegrationDb.Database);
|
||||
|
||||
await _repository.InsertOneAsync(configUnits);
|
||||
}
|
||||
|
||||
private ConfigUnitsRepository _repository;
|
||||
|
||||
@@ -42,19 +45,25 @@ public class ConfigUnitsRepositoryTest
|
||||
private IOptions<ApiSettings> _optionsApiSettings;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the repository's <c>FindById</c> method returns a non-null result when searching by the identifier "PV1".
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task FindById_Find_id_Return_List()
|
||||
{
|
||||
var result = await _repository.FindById("PV1");
|
||||
|
||||
Assert.That(result, Is.Not.Null);
|
||||
}
|
||||
public async Task FindById_Find_id_Return_List()
|
||||
{
|
||||
var result = await _repository.FindById("PV1");
|
||||
|
||||
Assert.That(result, Is.Not.Null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="ConfigUnitsRepository.FindById"/> returns null when invoked with an identifier ("PV2") that does not exist in the repository.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task FindAsync_not_Find_id_Return_Empty_List()
|
||||
{
|
||||
var result = await _repository.FindById("PV2");
|
||||
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
public async Task FindAsync_not_Find_id_Return_Empty_List()
|
||||
{
|
||||
var result = await _repository.FindById("PV2");
|
||||
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user