- Domain: Usuario.ForCreation factory, UsernameAlreadyExistsException, IUsuarioRepository extendido - Application: CreateUsuarioCommand/Validator/Handler, UsuarioCreatedDto, AuthOptions password policy - Infrastructure: UsuarioRepository.ExistsByUsernameAsync + AddAsync (INSERT OUTPUT INSERTED.Id), RoleClaimType="rol" en TokenValidationParameters - Api: UsuariosController POST api/v1/users [Authorize(Roles="admin")], ExceptionFilter mapea UsernameAlreadyExistsException + SqlException 2627 → 409 - Tests (unit): 43 tests — 33 validator + 10 handler (107 total, green) - Tests (integration): 7 tests CreateUsuarioEndpoint — 401/403/400/201/409/race/e2e (green) - Fix: TestWebAppFactory.ConfigureTestServices reemplaza SqlConnectionFactory singleton con CS de test correcto
12 lines
416 B
C#
12 lines
416 B
C#
using SIGCM2.Domain.Entities;
|
|
|
|
namespace SIGCM2.Application.Abstractions.Persistence;
|
|
|
|
public interface IUsuarioRepository
|
|
{
|
|
Task<Usuario?> GetByUsernameAsync(string username);
|
|
Task<Usuario?> GetByIdAsync(int id, CancellationToken ct = default);
|
|
Task<bool> ExistsByUsernameAsync(string username, CancellationToken ct = default);
|
|
Task<int> AddAsync(Usuario usuario, CancellationToken ct = default);
|
|
}
|