rama creada apartir de master en j

This commit is contained in:
jrojas
2026-06-26 10:29:23 +02:00
parent 319fd3dfb0
commit c1517fda87
2810 changed files with 1927392 additions and 25392 deletions
@@ -11,35 +11,38 @@ namespace adas_core.Test.Repositories;
[Category("Integration")]
public class UserRepositoryTest
{
/// <summary>
/// One-time integration test setup that prepares a clean "users" collection in the test database and seeds it with two predefined users, ensuring a deterministic state for downstream test cases.
/// </summary>
[OneTimeSetUp]
public async Task Init()
{
_optionsApiSettings = Options.Create(_apiSettings);
var user1 = new User
public async Task Init()
{
Id = ObjectId.GenerateNewId(),
UserName = "username1",
Password = "password1"
//Rol = "rol1"
};
var user2 = new User
{
Id = ObjectId.GenerateNewId(),
UserName = "username2",
Password = "password2"
//Rol = "rol2"
};
await IntegrationDb.Database.DropCollectionAsync("users");
await IntegrationDb.Database.CreateCollectionAsync("users");
_repository = new UserRepository(_optionsApiSettings, IntegrationDb.Database);
await _repository.InsertOneAsync(user1);
await _repository.InsertOneAsync(user2);
}
_optionsApiSettings = Options.Create(_apiSettings);
var user1 = new User
{
Id = ObjectId.GenerateNewId(),
UserName = "username1",
Password = "password1"
//Rol = "rol1"
};
var user2 = new User
{
Id = ObjectId.GenerateNewId(),
UserName = "username2",
Password = "password2"
//Rol = "rol2"
};
await IntegrationDb.Database.DropCollectionAsync("users");
await IntegrationDb.Database.CreateCollectionAsync("users");
_repository = new UserRepository(_optionsApiSettings, IntegrationDb.Database);
await _repository.InsertOneAsync(user1);
await _repository.InsertOneAsync(user2);
}
private UserRepository _repository = null!;
@@ -51,17 +54,20 @@ public class UserRepositoryTest
private IOptions<ApiSettings> _optionsApiSettings = null!;
/// <summary>
/// Verifies that the <see cref="_repository"/>'s <c>GetUser</c> method asynchronously returns a non-null user with the expected username and password credentials.
/// </summary>
[Test]
public async Task GetUser()
{
var result = await _repository.GetUser("username1", "password1");
Assert.That(result, Is.Not.Null);
using (Assert.EnterMultipleScope())
public async Task GetUser()
{
Assert.That(result!.UserName, Is.EqualTo("username1"));
Assert.That(result.Password, Is.EqualTo("password1"));
//Assert.That(result.Rol, Is.EqualTo("rol1"));
};
}
var result = await _repository.GetUser("username1", "password1");
Assert.That(result, Is.Not.Null);
using (Assert.EnterMultipleScope())
{
Assert.That(result!.UserName, Is.EqualTo("username1"));
Assert.That(result.Password, Is.EqualTo("password1"));
//Assert.That(result.Rol, Is.EqualTo("rol1"));
};
}
}