test(udt-011): T400.40 — update tests for TimeProvider injection and explicit now params
Fix all test compilation errors caused by T400.10/T400.20/T400.30: - Handler constructors: add TimeProvider.System as last argument - Domain mutator calls: add DateTime.UtcNow as explicit 'now' argument - AuditLogger/SecurityEventLogger Build() helpers: add TimeProvider.System - JwtService test constructors: add TimeProvider.System Cat2 coverage already present in TimeProviderArgentinaExtensionsTests.cs: FakeTimeProvider proves GetArgentinaToday() returns ART civil date, not UTC.
This commit is contained in:
@@ -44,7 +44,7 @@ public class LoginCommandHandlerTests
|
|||||||
_handler = new LoginCommandHandler(
|
_handler = new LoginCommandHandler(
|
||||||
_repository, _hasher, _jwtService,
|
_repository, _hasher, _jwtService,
|
||||||
_refreshRepo, _refreshGenerator, _clientCtx, _authOptions,
|
_refreshRepo, _refreshGenerator, _clientCtx, _authOptions,
|
||||||
_rolPermisoRepo, _security, _logger);
|
_rolPermisoRepo, _security, _logger, TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scenario: valid credentials → returns token response with usuario populated
|
// Scenario: valid credentials → returns token response with usuario populated
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class LogoutCommandHandlerTests
|
|||||||
|
|
||||||
public LogoutCommandHandlerTests()
|
public LogoutCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new LogoutCommandHandler(_refreshRepo, _security);
|
_handler = new LogoutCommandHandler(_refreshRepo, _security, TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ public class RefreshCommandHandlerTests
|
|||||||
_generator.Generate().Returns("new_raw_token_value_xyz");
|
_generator.Generate().Returns("new_raw_token_value_xyz");
|
||||||
|
|
||||||
_handler = new RefreshCommandHandler(
|
_handler = new RefreshCommandHandler(
|
||||||
_refreshRepo, _usuarioRepo, _jwtService, _generator, _clientCtx, _authOptions, _security);
|
_refreshRepo, _usuarioRepo, _jwtService, _generator, _clientCtx, _authOptions, _security,
|
||||||
|
TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper: build an active stored RefreshToken with a matching principal
|
// Helper: build an active stored RefreshToken with a matching principal
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class IngresosBrutosTests
|
|||||||
{
|
{
|
||||||
var original = MakeIIBB(descripcion: "Original");
|
var original = MakeIIBB(descripcion: "Original");
|
||||||
|
|
||||||
var updated = original.WithDescripcion("Actualizado");
|
var updated = original.WithDescripcion("Actualizado", DateTime.UtcNow);
|
||||||
|
|
||||||
updated.Should().NotBeSameAs(original);
|
updated.Should().NotBeSameAs(original);
|
||||||
updated.Descripcion.Should().Be("Actualizado");
|
updated.Descripcion.Should().Be("Actualizado");
|
||||||
@@ -107,7 +107,7 @@ public class IngresosBrutosTests
|
|||||||
{
|
{
|
||||||
var original = MakeIIBB(activo: true);
|
var original = MakeIIBB(activo: true);
|
||||||
|
|
||||||
var deactivated = original.Deactivate();
|
var deactivated = original.Deactivate(DateTime.UtcNow);
|
||||||
|
|
||||||
deactivated.Activo.Should().BeFalse();
|
deactivated.Activo.Should().BeFalse();
|
||||||
deactivated.Alicuota.Should().Be(original.Alicuota);
|
deactivated.Alicuota.Should().Be(original.Alicuota);
|
||||||
@@ -119,7 +119,7 @@ public class IngresosBrutosTests
|
|||||||
{
|
{
|
||||||
var original = MakeIIBB(activo: false);
|
var original = MakeIIBB(activo: false);
|
||||||
|
|
||||||
var reactivated = original.Reactivate();
|
var reactivated = original.Reactivate(DateTime.UtcNow);
|
||||||
|
|
||||||
reactivated.Activo.Should().BeTrue();
|
reactivated.Activo.Should().BeTrue();
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ public class IngresosBrutosTests
|
|||||||
var original = MakeIIBB(vigenciaHasta: null);
|
var original = MakeIIBB(vigenciaHasta: null);
|
||||||
var hasta = new DateOnly(2026, 5, 31);
|
var hasta = new DateOnly(2026, 5, 31);
|
||||||
|
|
||||||
var cerrado = original.CerrarVigencia(hasta);
|
var cerrado = original.CerrarVigencia(hasta, DateTime.UtcNow);
|
||||||
|
|
||||||
cerrado.VigenciaHasta.Should().Be(hasta);
|
cerrado.VigenciaHasta.Should().Be(hasta);
|
||||||
cerrado.Alicuota.Should().Be(original.Alicuota);
|
cerrado.Alicuota.Should().Be(original.Alicuota);
|
||||||
@@ -143,7 +143,7 @@ public class IngresosBrutosTests
|
|||||||
{
|
{
|
||||||
var predecesora = MakeIIBB(id: 5, alicuota: 2.5m, vigenciaDesde: Desde2020, vigenciaHasta: null);
|
var predecesora = MakeIIBB(id: 5, alicuota: 2.5m, vigenciaDesde: Desde2020, vigenciaHasta: null);
|
||||||
|
|
||||||
var (cerrada, nueva) = predecesora.NuevaVersion(3.0m, Desde2026);
|
var (cerrada, nueva) = predecesora.NuevaVersion(3.0m, Desde2026, DateTime.UtcNow);
|
||||||
|
|
||||||
cerrada.Id.Should().Be(5);
|
cerrada.Id.Should().Be(5);
|
||||||
cerrada.VigenciaHasta.Should().Be(Desde2026.AddDays(-1));
|
cerrada.VigenciaHasta.Should().Be(Desde2026.AddDays(-1));
|
||||||
@@ -166,7 +166,7 @@ public class IngresosBrutosTests
|
|||||||
vigenciaDesde: Desde2020,
|
vigenciaDesde: Desde2020,
|
||||||
vigenciaHasta: new DateOnly(2025, 12, 31));
|
vigenciaHasta: new DateOnly(2025, 12, 31));
|
||||||
|
|
||||||
var act = () => predecesora.NuevaVersion(4.0m, Desde2026);
|
var act = () => predecesora.NuevaVersion(4.0m, Desde2026, DateTime.UtcNow);
|
||||||
|
|
||||||
act.Should().Throw<InvalidOperationException>();
|
act.Should().Throw<InvalidOperationException>();
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ public class IngresosBrutosTests
|
|||||||
{
|
{
|
||||||
var predecesora = MakeIIBB(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
var predecesora = MakeIIBB(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
||||||
|
|
||||||
var act = () => predecesora.NuevaVersion(4.0m, Desde2020);
|
var act = () => predecesora.NuevaVersion(4.0m, Desde2020, DateTime.UtcNow);
|
||||||
|
|
||||||
act.Should().Throw<ArgumentException>()
|
act.Should().Throw<ArgumentException>()
|
||||||
.WithParameterName("vigenciaDesde");
|
.WithParameterName("vigenciaDesde");
|
||||||
@@ -187,7 +187,7 @@ public class IngresosBrutosTests
|
|||||||
{
|
{
|
||||||
var predecesora = MakeIIBB(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
var predecesora = MakeIIBB(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
||||||
|
|
||||||
var act = () => predecesora.NuevaVersion(-1m, Desde2026);
|
var act = () => predecesora.NuevaVersion(-1m, Desde2026, DateTime.UtcNow);
|
||||||
|
|
||||||
act.Should().Throw<ArgumentException>()
|
act.Should().Throw<ArgumentException>()
|
||||||
.WithParameterName("nuevaAlicuota");
|
.WithParameterName("nuevaAlicuota");
|
||||||
@@ -198,7 +198,7 @@ public class IngresosBrutosTests
|
|||||||
{
|
{
|
||||||
var predecesora = MakeIIBB(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
var predecesora = MakeIIBB(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
||||||
|
|
||||||
var act = () => predecesora.NuevaVersion(101m, Desde2026);
|
var act = () => predecesora.NuevaVersion(101m, Desde2026, DateTime.UtcNow);
|
||||||
|
|
||||||
act.Should().Throw<ArgumentException>()
|
act.Should().Throw<ArgumentException>()
|
||||||
.WithParameterName("nuevaAlicuota");
|
.WithParameterName("nuevaAlicuota");
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var original = MakeTipoDeIva(descripcion: "Original");
|
var original = MakeTipoDeIva(descripcion: "Original");
|
||||||
|
|
||||||
var updated = original.WithDescripcion("Nueva descripcion");
|
var updated = original.WithDescripcion("Nueva descripcion", DateTime.UtcNow);
|
||||||
|
|
||||||
updated.Should().NotBeSameAs(original);
|
updated.Should().NotBeSameAs(original);
|
||||||
updated.Descripcion.Should().Be("Nueva descripcion");
|
updated.Descripcion.Should().Be("Nueva descripcion");
|
||||||
@@ -162,7 +162,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var original = MakeTipoDeIva(codigo: "IVA_21");
|
var original = MakeTipoDeIva(codigo: "IVA_21");
|
||||||
|
|
||||||
var updated = original.WithCodigo("NO_GRAVADO");
|
var updated = original.WithCodigo("NO_GRAVADO", DateTime.UtcNow);
|
||||||
|
|
||||||
updated.Codigo.Should().Be("NO_GRAVADO");
|
updated.Codigo.Should().Be("NO_GRAVADO");
|
||||||
updated.Porcentaje.Should().Be(original.Porcentaje);
|
updated.Porcentaje.Should().Be(original.Porcentaje);
|
||||||
@@ -174,7 +174,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var original = MakeTipoDeIva(aplicaIVA: true);
|
var original = MakeTipoDeIva(aplicaIVA: true);
|
||||||
|
|
||||||
var updated = original.WithAplicaIVA(false);
|
var updated = original.WithAplicaIVA(false, DateTime.UtcNow);
|
||||||
|
|
||||||
updated.AplicaIVA.Should().BeFalse();
|
updated.AplicaIVA.Should().BeFalse();
|
||||||
updated.Porcentaje.Should().Be(original.Porcentaje);
|
updated.Porcentaje.Should().Be(original.Porcentaje);
|
||||||
@@ -185,7 +185,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var original = MakeTipoDeIva(activo: true);
|
var original = MakeTipoDeIva(activo: true);
|
||||||
|
|
||||||
var deactivated = original.Deactivate();
|
var deactivated = original.Deactivate(DateTime.UtcNow);
|
||||||
|
|
||||||
deactivated.Activo.Should().BeFalse();
|
deactivated.Activo.Should().BeFalse();
|
||||||
deactivated.Porcentaje.Should().Be(original.Porcentaje);
|
deactivated.Porcentaje.Should().Be(original.Porcentaje);
|
||||||
@@ -197,7 +197,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var original = MakeTipoDeIva(activo: false);
|
var original = MakeTipoDeIva(activo: false);
|
||||||
|
|
||||||
var reactivated = original.Reactivate();
|
var reactivated = original.Reactivate(DateTime.UtcNow);
|
||||||
|
|
||||||
reactivated.Activo.Should().BeTrue();
|
reactivated.Activo.Should().BeTrue();
|
||||||
}
|
}
|
||||||
@@ -208,7 +208,7 @@ public class TipoDeIvaTests
|
|||||||
var original = MakeTipoDeIva(vigenciaHasta: null);
|
var original = MakeTipoDeIva(vigenciaHasta: null);
|
||||||
var hasta = new DateOnly(2026, 5, 31);
|
var hasta = new DateOnly(2026, 5, 31);
|
||||||
|
|
||||||
var cerrado = original.CerrarVigencia(hasta);
|
var cerrado = original.CerrarVigencia(hasta, DateTime.UtcNow);
|
||||||
|
|
||||||
cerrado.VigenciaHasta.Should().Be(hasta);
|
cerrado.VigenciaHasta.Should().Be(hasta);
|
||||||
cerrado.Porcentaje.Should().Be(original.Porcentaje);
|
cerrado.Porcentaje.Should().Be(original.Porcentaje);
|
||||||
@@ -222,7 +222,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var predecesora = MakeTipoDeIva(id: 5, porcentaje: 21m, vigenciaDesde: Desde2020, vigenciaHasta: null);
|
var predecesora = MakeTipoDeIva(id: 5, porcentaje: 21m, vigenciaDesde: Desde2020, vigenciaHasta: null);
|
||||||
|
|
||||||
var (cerrada, nueva) = predecesora.NuevaVersion(23.5m, Desde2026);
|
var (cerrada, nueva) = predecesora.NuevaVersion(23.5m, Desde2026, DateTime.UtcNow);
|
||||||
|
|
||||||
cerrada.Id.Should().Be(5);
|
cerrada.Id.Should().Be(5);
|
||||||
cerrada.VigenciaHasta.Should().Be(Desde2026.AddDays(-1), "predecesora queda cerrada el día anterior");
|
cerrada.VigenciaHasta.Should().Be(Desde2026.AddDays(-1), "predecesora queda cerrada el día anterior");
|
||||||
@@ -244,7 +244,7 @@ public class TipoDeIvaTests
|
|||||||
var predecesora = MakeTipoDeIva(porcentaje: 10.5m, vigenciaDesde: Desde2020);
|
var predecesora = MakeTipoDeIva(porcentaje: 10.5m, vigenciaDesde: Desde2020);
|
||||||
var nuevaVigencia = new DateOnly(2025, 1, 1);
|
var nuevaVigencia = new DateOnly(2025, 1, 1);
|
||||||
|
|
||||||
var (_, nueva) = predecesora.NuevaVersion(21m, nuevaVigencia);
|
var (_, nueva) = predecesora.NuevaVersion(21m, nuevaVigencia, DateTime.UtcNow);
|
||||||
|
|
||||||
nueva.Porcentaje.Should().Be(21m);
|
nueva.Porcentaje.Should().Be(21m);
|
||||||
predecesora.Porcentaje.Should().Be(10.5m, "predecesora no muta");
|
predecesora.Porcentaje.Should().Be(10.5m, "predecesora no muta");
|
||||||
@@ -259,7 +259,7 @@ public class TipoDeIvaTests
|
|||||||
vigenciaDesde: Desde2020,
|
vigenciaDesde: Desde2020,
|
||||||
vigenciaHasta: new DateOnly(2025, 12, 31)); // ya cerrada
|
vigenciaHasta: new DateOnly(2025, 12, 31)); // ya cerrada
|
||||||
|
|
||||||
var act = () => predecesora.NuevaVersion(23.5m, Desde2026);
|
var act = () => predecesora.NuevaVersion(23.5m, Desde2026, DateTime.UtcNow);
|
||||||
|
|
||||||
act.Should().Throw<InvalidOperationException>();
|
act.Should().Throw<InvalidOperationException>();
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var predecesora = MakeTipoDeIva(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
var predecesora = MakeTipoDeIva(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
||||||
|
|
||||||
var act = () => predecesora.NuevaVersion(23.5m, Desde2020); // igual a VigenciaDesde predecesora
|
var act = () => predecesora.NuevaVersion(23.5m, Desde2020, DateTime.UtcNow); // igual a VigenciaDesde predecesora
|
||||||
|
|
||||||
act.Should().Throw<ArgumentException>()
|
act.Should().Throw<ArgumentException>()
|
||||||
.WithParameterName("vigenciaDesde");
|
.WithParameterName("vigenciaDesde");
|
||||||
@@ -281,7 +281,7 @@ public class TipoDeIvaTests
|
|||||||
var predecesora = MakeTipoDeIva(vigenciaDesde: Desde2026, vigenciaHasta: null);
|
var predecesora = MakeTipoDeIva(vigenciaDesde: Desde2026, vigenciaHasta: null);
|
||||||
var vigenciaAnterior = new DateOnly(2020, 1, 1);
|
var vigenciaAnterior = new DateOnly(2020, 1, 1);
|
||||||
|
|
||||||
var act = () => predecesora.NuevaVersion(23.5m, vigenciaAnterior);
|
var act = () => predecesora.NuevaVersion(23.5m, vigenciaAnterior, DateTime.UtcNow);
|
||||||
|
|
||||||
act.Should().Throw<ArgumentException>()
|
act.Should().Throw<ArgumentException>()
|
||||||
.WithParameterName("vigenciaDesde");
|
.WithParameterName("vigenciaDesde");
|
||||||
@@ -292,7 +292,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var predecesora = MakeTipoDeIva(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
var predecesora = MakeTipoDeIva(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
||||||
|
|
||||||
var act = () => predecesora.NuevaVersion(-1m, Desde2026);
|
var act = () => predecesora.NuevaVersion(-1m, Desde2026, DateTime.UtcNow);
|
||||||
|
|
||||||
act.Should().Throw<ArgumentException>()
|
act.Should().Throw<ArgumentException>()
|
||||||
.WithParameterName("nuevoPorcentaje");
|
.WithParameterName("nuevoPorcentaje");
|
||||||
@@ -303,7 +303,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var predecesora = MakeTipoDeIva(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
var predecesora = MakeTipoDeIva(vigenciaDesde: Desde2020, vigenciaHasta: null);
|
||||||
|
|
||||||
var act = () => predecesora.NuevaVersion(101m, Desde2026);
|
var act = () => predecesora.NuevaVersion(101m, Desde2026, DateTime.UtcNow);
|
||||||
|
|
||||||
act.Should().Throw<ArgumentException>()
|
act.Should().Throw<ArgumentException>()
|
||||||
.WithParameterName("nuevoPorcentaje");
|
.WithParameterName("nuevoPorcentaje");
|
||||||
@@ -326,7 +326,7 @@ public class TipoDeIvaTests
|
|||||||
{
|
{
|
||||||
var original = MakeTipoDeIva(id: 99, porcentaje: 21m, vigenciaDesde: Desde2020);
|
var original = MakeTipoDeIva(id: 99, porcentaje: 21m, vigenciaDesde: Desde2020);
|
||||||
|
|
||||||
var updated = original.WithDescripcion("Nueva");
|
var updated = original.WithDescripcion("Nueva", DateTime.UtcNow);
|
||||||
|
|
||||||
updated.Id.Should().Be(99);
|
updated.Id.Should().Be(99);
|
||||||
updated.Porcentaje.Should().Be(21m);
|
updated.Porcentaje.Should().Be(21m);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class PuntoDeVentaTests
|
|||||||
{
|
{
|
||||||
var original = MakePdv(id: 10, nombre: "Original");
|
var original = MakePdv(id: 10, nombre: "Original");
|
||||||
|
|
||||||
var updated = original.WithUpdatedProfile(nombre: "Actualizado", numeroAFIP: 7, descripcion: "Desc");
|
var updated = original.WithUpdatedProfile(nombre: "Actualizado", numeroAFIP: 7, descripcion: "Desc", now: DateTime.UtcNow);
|
||||||
|
|
||||||
Assert.NotSame(original, updated);
|
Assert.NotSame(original, updated);
|
||||||
Assert.Equal("Actualizado", updated.Nombre);
|
Assert.Equal("Actualizado", updated.Nombre);
|
||||||
@@ -56,7 +56,7 @@ public class PuntoDeVentaTests
|
|||||||
{
|
{
|
||||||
var original = MakePdv(id: 10, medioId: 5);
|
var original = MakePdv(id: 10, medioId: 5);
|
||||||
|
|
||||||
var updated = original.WithUpdatedProfile("Nuevo", 2, null);
|
var updated = original.WithUpdatedProfile("Nuevo", 2, null, DateTime.UtcNow);
|
||||||
|
|
||||||
Assert.Equal(10, updated.Id);
|
Assert.Equal(10, updated.Id);
|
||||||
Assert.Equal(5, updated.MedioId);
|
Assert.Equal(5, updated.MedioId);
|
||||||
@@ -69,7 +69,7 @@ public class PuntoDeVentaTests
|
|||||||
{
|
{
|
||||||
var original = MakePdv();
|
var original = MakePdv();
|
||||||
|
|
||||||
var updated = original.WithUpdatedProfile("Nuevo", 2, null);
|
var updated = original.WithUpdatedProfile("Nuevo", 2, null, DateTime.UtcNow);
|
||||||
|
|
||||||
Assert.NotNull(updated.FechaModificacion);
|
Assert.NotNull(updated.FechaModificacion);
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ public class PuntoDeVentaTests
|
|||||||
{
|
{
|
||||||
var pdv = MakePdv(activo: true);
|
var pdv = MakePdv(activo: true);
|
||||||
|
|
||||||
var deactivated = pdv.WithActivo(false);
|
var deactivated = pdv.WithActivo(false, DateTime.UtcNow);
|
||||||
|
|
||||||
Assert.False(deactivated.Activo);
|
Assert.False(deactivated.Activo);
|
||||||
Assert.NotSame(pdv, deactivated);
|
Assert.NotSame(pdv, deactivated);
|
||||||
@@ -92,7 +92,7 @@ public class PuntoDeVentaTests
|
|||||||
{
|
{
|
||||||
var pdv = MakePdv(activo: false);
|
var pdv = MakePdv(activo: false);
|
||||||
|
|
||||||
var reactivated = pdv.WithActivo(true);
|
var reactivated = pdv.WithActivo(true, DateTime.UtcNow);
|
||||||
|
|
||||||
Assert.True(reactivated.Activo);
|
Assert.True(reactivated.Activo);
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ public class PuntoDeVentaTests
|
|||||||
{
|
{
|
||||||
var pdv = MakePdv(id: 99, medioId: 3);
|
var pdv = MakePdv(id: 99, medioId: 3);
|
||||||
|
|
||||||
var toggled = pdv.WithActivo(false);
|
var toggled = pdv.WithActivo(false, DateTime.UtcNow);
|
||||||
|
|
||||||
Assert.Equal(99, toggled.Id);
|
Assert.Equal(99, toggled.Id);
|
||||||
Assert.Equal(3, toggled.MedioId);
|
Assert.Equal(3, toggled.MedioId);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public class UsuarioTests
|
|||||||
public void WithUpdatedProfile_Returns_NewInstance()
|
public void WithUpdatedProfile_Returns_NewInstance()
|
||||||
{
|
{
|
||||||
var u = MakeUsuario();
|
var u = MakeUsuario();
|
||||||
var updated = u.WithUpdatedProfile("NuevoNombre", "NuevoApellido", "new@x.com", "cajero", true);
|
var updated = u.WithUpdatedProfile("NuevoNombre", "NuevoApellido", "new@x.com", "cajero", true, DateTime.UtcNow);
|
||||||
Assert.NotSame(u, updated);
|
Assert.NotSame(u, updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ public class UsuarioTests
|
|||||||
public void WithUpdatedProfile_Sets_Fields_Correctly()
|
public void WithUpdatedProfile_Sets_Fields_Correctly()
|
||||||
{
|
{
|
||||||
var u = MakeUsuario();
|
var u = MakeUsuario();
|
||||||
var updated = u.WithUpdatedProfile("Pedro", "Gómez", "p@g.com", "cajero", false);
|
var updated = u.WithUpdatedProfile("Pedro", "Gómez", "p@g.com", "cajero", false, DateTime.UtcNow);
|
||||||
Assert.Equal("Pedro", updated.Nombre);
|
Assert.Equal("Pedro", updated.Nombre);
|
||||||
Assert.Equal("Gómez", updated.Apellido);
|
Assert.Equal("Gómez", updated.Apellido);
|
||||||
Assert.Equal("p@g.com", updated.Email);
|
Assert.Equal("p@g.com", updated.Email);
|
||||||
@@ -121,8 +121,9 @@ public class UsuarioTests
|
|||||||
public void WithUpdatedProfile_Sets_FechaModificacion_To_UtcNow()
|
public void WithUpdatedProfile_Sets_FechaModificacion_To_UtcNow()
|
||||||
{
|
{
|
||||||
var before = DateTime.UtcNow.AddSeconds(-1);
|
var before = DateTime.UtcNow.AddSeconds(-1);
|
||||||
|
var now = DateTime.UtcNow;
|
||||||
var u = MakeUsuario();
|
var u = MakeUsuario();
|
||||||
var updated = u.WithUpdatedProfile("A", "B", null, "admin", true);
|
var updated = u.WithUpdatedProfile("A", "B", null, "admin", true, now);
|
||||||
Assert.NotNull(updated.FechaModificacion);
|
Assert.NotNull(updated.FechaModificacion);
|
||||||
Assert.True(updated.FechaModificacion >= before);
|
Assert.True(updated.FechaModificacion >= before);
|
||||||
}
|
}
|
||||||
@@ -131,7 +132,7 @@ public class UsuarioTests
|
|||||||
public void WithUpdatedProfile_Preserves_Immutable_Fields()
|
public void WithUpdatedProfile_Preserves_Immutable_Fields()
|
||||||
{
|
{
|
||||||
var u = MakeUsuario();
|
var u = MakeUsuario();
|
||||||
var updated = u.WithUpdatedProfile("X", "Y", null, "cajero", true);
|
var updated = u.WithUpdatedProfile("X", "Y", null, "cajero", true, DateTime.UtcNow);
|
||||||
Assert.Equal(u.Id, updated.Id);
|
Assert.Equal(u.Id, updated.Id);
|
||||||
Assert.Equal(u.Username, updated.Username);
|
Assert.Equal(u.Username, updated.Username);
|
||||||
Assert.Equal(u.PasswordHash, updated.PasswordHash);
|
Assert.Equal(u.PasswordHash, updated.PasswordHash);
|
||||||
@@ -143,7 +144,7 @@ public class UsuarioTests
|
|||||||
public void WithNewPasswordHash_Returns_NewInstance()
|
public void WithNewPasswordHash_Returns_NewInstance()
|
||||||
{
|
{
|
||||||
var u = MakeUsuario();
|
var u = MakeUsuario();
|
||||||
var updated = u.WithNewPasswordHash("newhash", mustChangePassword: false);
|
var updated = u.WithNewPasswordHash("newhash", mustChangePassword: false, DateTime.UtcNow);
|
||||||
Assert.NotSame(u, updated);
|
Assert.NotSame(u, updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +152,7 @@ public class UsuarioTests
|
|||||||
public void WithNewPasswordHash_Sets_Hash_And_MustChange()
|
public void WithNewPasswordHash_Sets_Hash_And_MustChange()
|
||||||
{
|
{
|
||||||
var u = MakeUsuario();
|
var u = MakeUsuario();
|
||||||
var updated = u.WithNewPasswordHash("newhash", mustChangePassword: true);
|
var updated = u.WithNewPasswordHash("newhash", mustChangePassword: true, DateTime.UtcNow);
|
||||||
Assert.Equal("newhash", updated.PasswordHash);
|
Assert.Equal("newhash", updated.PasswordHash);
|
||||||
Assert.True(updated.MustChangePassword);
|
Assert.True(updated.MustChangePassword);
|
||||||
}
|
}
|
||||||
@@ -160,7 +161,7 @@ public class UsuarioTests
|
|||||||
public void WithNewPasswordHash_Clears_MustChange_When_False()
|
public void WithNewPasswordHash_Clears_MustChange_When_False()
|
||||||
{
|
{
|
||||||
var u = MakeUsuario(mustChangePassword: true);
|
var u = MakeUsuario(mustChangePassword: true);
|
||||||
var updated = u.WithNewPasswordHash("hash2", mustChangePassword: false);
|
var updated = u.WithNewPasswordHash("hash2", mustChangePassword: false, DateTime.UtcNow);
|
||||||
Assert.False(updated.MustChangePassword);
|
Assert.False(updated.MustChangePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,8 +169,9 @@ public class UsuarioTests
|
|||||||
public void WithNewPasswordHash_Sets_FechaModificacion()
|
public void WithNewPasswordHash_Sets_FechaModificacion()
|
||||||
{
|
{
|
||||||
var before = DateTime.UtcNow.AddSeconds(-1);
|
var before = DateTime.UtcNow.AddSeconds(-1);
|
||||||
|
var now = DateTime.UtcNow;
|
||||||
var u = MakeUsuario();
|
var u = MakeUsuario();
|
||||||
var updated = u.WithNewPasswordHash("hash2", false);
|
var updated = u.WithNewPasswordHash("hash2", false, now);
|
||||||
Assert.NotNull(updated.FechaModificacion);
|
Assert.NotNull(updated.FechaModificacion);
|
||||||
Assert.True(updated.FechaModificacion >= before);
|
Assert.True(updated.FechaModificacion >= before);
|
||||||
}
|
}
|
||||||
@@ -208,7 +210,7 @@ public class UsuarioTests
|
|||||||
public void WithMustChangePassword_Sets_Value_True()
|
public void WithMustChangePassword_Sets_Value_True()
|
||||||
{
|
{
|
||||||
var u = MakeUsuario(mustChangePassword: false);
|
var u = MakeUsuario(mustChangePassword: false);
|
||||||
var updated = u.WithMustChangePassword(true);
|
var updated = u.WithMustChangePassword(true, DateTime.UtcNow);
|
||||||
Assert.True(updated.MustChangePassword);
|
Assert.True(updated.MustChangePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,8 +218,9 @@ public class UsuarioTests
|
|||||||
public void WithMustChangePassword_Sets_FechaModificacion()
|
public void WithMustChangePassword_Sets_FechaModificacion()
|
||||||
{
|
{
|
||||||
var before = DateTime.UtcNow.AddSeconds(-1);
|
var before = DateTime.UtcNow.AddSeconds(-1);
|
||||||
|
var now = DateTime.UtcNow;
|
||||||
var u = MakeUsuario();
|
var u = MakeUsuario();
|
||||||
var updated = u.WithMustChangePassword(true);
|
var updated = u.WithMustChangePassword(true, now);
|
||||||
Assert.NotNull(updated.FechaModificacion);
|
Assert.NotNull(updated.FechaModificacion);
|
||||||
Assert.True(updated.FechaModificacion >= before);
|
Assert.True(updated.FechaModificacion >= before);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public sealed class AuditLoggerTests
|
|||||||
repo ??= Substitute.For<IAuditEventRepository>();
|
repo ??= Substitute.For<IAuditEventRepository>();
|
||||||
options ??= new AuditOptions();
|
options ??= new AuditOptions();
|
||||||
var optsWrapper = Options.Create(options);
|
var optsWrapper = Options.Create(options);
|
||||||
return new AuditLogger(context, repo, optsWrapper);
|
return new AuditLogger(context, repo, optsWrapper, TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public sealed class SecurityEventLoggerTests
|
|||||||
repo ??= Substitute.For<ISecurityEventRepository>();
|
repo ??= Substitute.For<ISecurityEventRepository>();
|
||||||
context ??= Substitute.For<IAuditContext>();
|
context ??= Substitute.For<IAuditContext>();
|
||||||
options ??= new AuditOptions();
|
options ??= new AuditOptions();
|
||||||
return new SecurityEventLogger(repo, context, Options.Create(options));
|
return new SecurityEventLogger(repo, context, Options.Create(options), TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class JwtServiceTests : IDisposable
|
|||||||
Audience = "sigcm2.web",
|
Audience = "sigcm2.web",
|
||||||
AccessTokenMinutes = 60
|
AccessTokenMinutes = 60
|
||||||
};
|
};
|
||||||
_jwtService = new JwtService(_rsa, _options);
|
_jwtService = new JwtService(_rsa, _options, TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() => _rsa.Dispose();
|
public void Dispose() => _rsa.Dispose();
|
||||||
@@ -219,7 +219,7 @@ public class JwtServiceTests : IDisposable
|
|||||||
// Sign with a different RSA key
|
// Sign with a different RSA key
|
||||||
using var otherRsa = System.Security.Cryptography.RSA.Create(2048);
|
using var otherRsa = System.Security.Cryptography.RSA.Create(2048);
|
||||||
var otherOptions = new JwtOptions { Issuer = "sigcm2.api", Audience = "sigcm2.web", AccessTokenMinutes = 60 };
|
var otherOptions = new JwtOptions { Issuer = "sigcm2.api", Audience = "sigcm2.web", AccessTokenMinutes = 60 };
|
||||||
var otherService = new JwtService(otherRsa, otherOptions);
|
var otherService = new JwtService(otherRsa, otherOptions, TimeProvider.System);
|
||||||
var tokenFromOtherKey = otherService.GenerateAccessToken(MakeUsuario());
|
var tokenFromOtherKey = otherService.GenerateAccessToken(MakeUsuario());
|
||||||
|
|
||||||
// Validating with the correct key should throw
|
// Validating with the correct key should throw
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class CreateIngresosBrutosCommandHandlerTests
|
|||||||
|
|
||||||
public CreateIngresosBrutosCommandHandlerTests()
|
public CreateIngresosBrutosCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new CreateIngresosBrutosCommandHandler(_repo, _audit);
|
_handler = new CreateIngresosBrutosCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.InsertAsync(Arg.Any<IibbEntity>(), Arg.Any<CancellationToken>()).Returns(55);
|
_repo.InsertAsync(Arg.Any<IibbEntity>(), Arg.Any<CancellationToken>()).Returns(55);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class DeactivateIngresosBrutosCommandHandlerTests
|
|||||||
|
|
||||||
public DeactivateIngresosBrutosCommandHandlerTests()
|
public DeactivateIngresosBrutosCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new DeactivateIngresosBrutosCommandHandler(_repo, _audit);
|
_handler = new DeactivateIngresosBrutosCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
||||||
_repo.SetActivoAsync(Arg.Any<int>(), Arg.Any<bool>(), Arg.Any<CancellationToken>()).Returns(true);
|
_repo.SetActivoAsync(Arg.Any<int>(), Arg.Any<bool>(), Arg.Any<CancellationToken>()).Returns(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class NuevaVersionIngresosBrutosCommandHandlerTests
|
|||||||
|
|
||||||
public NuevaVersionIngresosBrutosCommandHandlerTests()
|
public NuevaVersionIngresosBrutosCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new NuevaVersionIngresosBrutosCommandHandler(_repo, _audit);
|
_handler = new NuevaVersionIngresosBrutosCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakePredecesora());
|
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakePredecesora());
|
||||||
_repo.UpdateCierreVigenciaAsync(Arg.Any<int>(), Arg.Any<DateOnly>(), Arg.Any<CancellationToken>()).Returns(true);
|
_repo.UpdateCierreVigenciaAsync(Arg.Any<int>(), Arg.Any<DateOnly>(), Arg.Any<CancellationToken>()).Returns(true);
|
||||||
_repo.InsertAsync(Arg.Any<IibbEntity>(), Arg.Any<CancellationToken>()).Returns(88);
|
_repo.InsertAsync(Arg.Any<IibbEntity>(), Arg.Any<CancellationToken>()).Returns(88);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class ReactivateIngresosBrutosCommandHandlerTests
|
|||||||
|
|
||||||
public ReactivateIngresosBrutosCommandHandlerTests()
|
public ReactivateIngresosBrutosCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new ReactivateIngresosBrutosCommandHandler(_repo, _audit);
|
_handler = new ReactivateIngresosBrutosCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
||||||
_repo.SetActivoAsync(Arg.Any<int>(), Arg.Any<bool>(), Arg.Any<CancellationToken>()).Returns(true);
|
_repo.SetActivoAsync(Arg.Any<int>(), Arg.Any<bool>(), Arg.Any<CancellationToken>()).Returns(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class UpdateIngresosBrutosCommandHandlerTests
|
|||||||
|
|
||||||
public UpdateIngresosBrutosCommandHandlerTests()
|
public UpdateIngresosBrutosCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new UpdateIngresosBrutosCommandHandler(_repo, _audit);
|
_handler = new UpdateIngresosBrutosCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
||||||
_repo.UpdateCosmeticoAsync(Arg.Any<int>(), Arg.Any<string>(), Arg.Any<bool>(),
|
_repo.UpdateCosmeticoAsync(Arg.Any<int>(), Arg.Any<string>(), Arg.Any<bool>(),
|
||||||
Arg.Any<CancellationToken>()).Returns(true);
|
Arg.Any<CancellationToken>()).Returns(true);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class DeactivateMedioCommandHandlerTests
|
|||||||
|
|
||||||
public DeactivateMedioCommandHandlerTests()
|
public DeactivateMedioCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new DeactivateMedioCommandHandler(_repo, _audit);
|
_handler = new DeactivateMedioCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── not found → throws ──────────────────────────────────────────────────
|
// ── not found → throws ──────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public class MedioRepositoryTests : IAsyncLifetime
|
|||||||
var id = await _repository.AddAsync(Medio.ForCreation("UPD01", "Original", TipoMedio.Diario, null));
|
var id = await _repository.AddAsync(Medio.ForCreation("UPD01", "Original", TipoMedio.Diario, null));
|
||||||
var original = await _repository.GetByIdAsync(id);
|
var original = await _repository.GetByIdAsync(id);
|
||||||
|
|
||||||
var updated = original!.WithUpdatedProfile("Actualizado", TipoMedio.Radio, 7);
|
var updated = original!.WithUpdatedProfile("Actualizado", TipoMedio.Radio, 7, DateTime.UtcNow);
|
||||||
await _repository.UpdateAsync(updated);
|
await _repository.UpdateAsync(updated);
|
||||||
|
|
||||||
var result = await _repository.GetByIdAsync(id);
|
var result = await _repository.GetByIdAsync(id);
|
||||||
@@ -167,7 +167,7 @@ public class MedioRepositoryTests : IAsyncLifetime
|
|||||||
var id = await _repository.AddAsync(Medio.ForCreation("HIST01", "Historial", TipoMedio.Diario, null));
|
var id = await _repository.AddAsync(Medio.ForCreation("HIST01", "Historial", TipoMedio.Diario, null));
|
||||||
var original = await _repository.GetByIdAsync(id);
|
var original = await _repository.GetByIdAsync(id);
|
||||||
|
|
||||||
var updated = original!.WithUpdatedProfile("Historial v2", TipoMedio.Web, null);
|
var updated = original!.WithUpdatedProfile("Historial v2", TipoMedio.Web, null, DateTime.UtcNow);
|
||||||
await _repository.UpdateAsync(updated);
|
await _repository.UpdateAsync(updated);
|
||||||
|
|
||||||
var historyCount = await _connection.ExecuteScalarAsync<int>(
|
var historyCount = await _connection.ExecuteScalarAsync<int>(
|
||||||
@@ -186,7 +186,7 @@ public class MedioRepositoryTests : IAsyncLifetime
|
|||||||
|
|
||||||
// Deactivate second medio
|
// Deactivate second medio
|
||||||
var inact = await _repository.GetByIdAsync(idInact);
|
var inact = await _repository.GetByIdAsync(idInact);
|
||||||
await _repository.UpdateAsync(inact!.WithActivo(false));
|
await _repository.UpdateAsync(inact!.WithActivo(false, DateTime.UtcNow));
|
||||||
|
|
||||||
var result = await _repository.GetPagedAsync(new(Page: 1, PageSize: 50, Activo: true, Tipo: null, Search: null));
|
var result = await _repository.GetPagedAsync(new(Page: 1, PageSize: 50, Activo: true, Tipo: null, Search: null));
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class ReactivateMedioCommandHandlerTests
|
|||||||
|
|
||||||
public ReactivateMedioCommandHandlerTests()
|
public ReactivateMedioCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new ReactivateMedioCommandHandler(_repo, _audit);
|
_handler = new ReactivateMedioCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── not found → throws ──────────────────────────────────────────────────
|
// ── not found → throws ──────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class UpdateMedioCommandHandlerTests
|
|||||||
|
|
||||||
public UpdateMedioCommandHandlerTests()
|
public UpdateMedioCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new UpdateMedioCommandHandler(_repo, _audit);
|
_handler = new UpdateMedioCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── not found → throws ──────────────────────────────────────────────────
|
// ── not found → throws ──────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class DeactivatePuntoDeVentaCommandHandlerTests
|
|||||||
|
|
||||||
public DeactivatePuntoDeVentaCommandHandlerTests()
|
public DeactivatePuntoDeVentaCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new DeactivatePuntoDeVentaCommandHandler(_repo, _medioRepo, _audit);
|
_handler = new DeactivatePuntoDeVentaCommandHandler(_repo, _medioRepo, _audit, TimeProvider.System);
|
||||||
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(5, true));
|
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(5, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class ReactivatePuntoDeVentaCommandHandlerTests
|
|||||||
|
|
||||||
public ReactivatePuntoDeVentaCommandHandlerTests()
|
public ReactivatePuntoDeVentaCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new ReactivatePuntoDeVentaCommandHandler(_repo, _medioRepo, _audit);
|
_handler = new ReactivatePuntoDeVentaCommandHandler(_repo, _medioRepo, _audit, TimeProvider.System);
|
||||||
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(5, true));
|
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(5, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class UpdatePuntoDeVentaCommandHandlerTests
|
|||||||
|
|
||||||
public UpdatePuntoDeVentaCommandHandlerTests()
|
public UpdatePuntoDeVentaCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new UpdatePuntoDeVentaCommandHandler(_repo, _medioRepo, _audit);
|
_handler = new UpdatePuntoDeVentaCommandHandler(_repo, _medioRepo, _audit, TimeProvider.System);
|
||||||
_repo.GetByIdAsync(10, Arg.Any<CancellationToken>()).Returns(MakePdv(10));
|
_repo.GetByIdAsync(10, Arg.Any<CancellationToken>()).Returns(MakePdv(10));
|
||||||
_medioRepo.GetByIdAsync(5, Arg.Any<CancellationToken>()).Returns(MakeMedio(5));
|
_medioRepo.GetByIdAsync(5, Arg.Any<CancellationToken>()).Returns(MakeMedio(5));
|
||||||
_repo.ExistsByNumeroAFIPInMedioAsync(Arg.Any<int>(), Arg.Any<short>(), Arg.Any<int?>(), Arg.Any<CancellationToken>()).Returns(false);
|
_repo.ExistsByNumeroAFIPInMedioAsync(Arg.Any<int>(), Arg.Any<short>(), Arg.Any<int?>(), Arg.Any<CancellationToken>()).Returns(false);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class DeactivateSeccionCommandHandlerTests
|
|||||||
|
|
||||||
public DeactivateSeccionCommandHandlerTests()
|
public DeactivateSeccionCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new DeactivateSeccionCommandHandler(_repo, _medioRepo, _audit);
|
_handler = new DeactivateSeccionCommandHandler(_repo, _medioRepo, _audit, TimeProvider.System);
|
||||||
// Default: medio is active
|
// Default: medio is active
|
||||||
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(1, true));
|
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(1, true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class ReactivateSeccionCommandHandlerTests
|
|||||||
|
|
||||||
public ReactivateSeccionCommandHandlerTests()
|
public ReactivateSeccionCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new ReactivateSeccionCommandHandler(_repo, _medioRepo, _audit);
|
_handler = new ReactivateSeccionCommandHandler(_repo, _medioRepo, _audit, TimeProvider.System);
|
||||||
// Default: medio is active
|
// Default: medio is active
|
||||||
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(1, true));
|
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(1, true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class SeccionRepositoryTests : IAsyncLifetime
|
|||||||
var id = await _repository.AddAsync(Seccion.ForCreation(_medioId, "UPD01", "Original", "clasificados"));
|
var id = await _repository.AddAsync(Seccion.ForCreation(_medioId, "UPD01", "Original", "clasificados"));
|
||||||
var original = await _repository.GetByIdAsync(id);
|
var original = await _repository.GetByIdAsync(id);
|
||||||
|
|
||||||
var updated = original!.WithUpdatedProfile("Actualizado", "notables");
|
var updated = original!.WithUpdatedProfile("Actualizado", "notables", DateTime.UtcNow);
|
||||||
await _repository.UpdateAsync(updated);
|
await _repository.UpdateAsync(updated);
|
||||||
|
|
||||||
var result = await _repository.GetByIdAsync(id);
|
var result = await _repository.GetByIdAsync(id);
|
||||||
@@ -168,7 +168,7 @@ public class SeccionRepositoryTests : IAsyncLifetime
|
|||||||
var id = await _repository.AddAsync(Seccion.ForCreation(_medioId, "HIST01", "Historial", "clasificados"));
|
var id = await _repository.AddAsync(Seccion.ForCreation(_medioId, "HIST01", "Historial", "clasificados"));
|
||||||
var original = await _repository.GetByIdAsync(id);
|
var original = await _repository.GetByIdAsync(id);
|
||||||
|
|
||||||
var updated = original!.WithUpdatedProfile("Historial v2", "suplementos");
|
var updated = original!.WithUpdatedProfile("Historial v2", "suplementos", DateTime.UtcNow);
|
||||||
await _repository.UpdateAsync(updated);
|
await _repository.UpdateAsync(updated);
|
||||||
|
|
||||||
var historyCount = await _connection.ExecuteScalarAsync<int>(
|
var historyCount = await _connection.ExecuteScalarAsync<int>(
|
||||||
@@ -213,7 +213,7 @@ public class SeccionRepositoryTests : IAsyncLifetime
|
|||||||
var inactId = await _repository.AddAsync(Seccion.ForCreation(_medioId, "INACT01", "Inactiva", "clasificados"));
|
var inactId = await _repository.AddAsync(Seccion.ForCreation(_medioId, "INACT01", "Inactiva", "clasificados"));
|
||||||
|
|
||||||
var inact = await _repository.GetByIdAsync(inactId);
|
var inact = await _repository.GetByIdAsync(inactId);
|
||||||
await _repository.UpdateAsync(inact!.WithActivo(false));
|
await _repository.UpdateAsync(inact!.WithActivo(false, DateTime.UtcNow));
|
||||||
|
|
||||||
var result = await _repository.GetPagedAsync(new(Page: 1, PageSize: 50, MedioId: _medioId, Tipo: null, Activo: true, Search: null));
|
var result = await _repository.GetPagedAsync(new(Page: 1, PageSize: 50, MedioId: _medioId, Tipo: null, Activo: true, Search: null));
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class UpdateSeccionCommandHandlerTests
|
|||||||
|
|
||||||
public UpdateSeccionCommandHandlerTests()
|
public UpdateSeccionCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new UpdateSeccionCommandHandler(_repo, _medioRepo, _audit);
|
_handler = new UpdateSeccionCommandHandler(_repo, _medioRepo, _audit, TimeProvider.System);
|
||||||
// Default: medio is active
|
// Default: medio is active
|
||||||
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(1, true));
|
_medioRepo.GetByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(MakeMedio(1, true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class CreateTipoDeIvaCommandHandlerTests
|
|||||||
|
|
||||||
public CreateTipoDeIvaCommandHandlerTests()
|
public CreateTipoDeIvaCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new CreateTipoDeIvaCommandHandler(_repo, _audit);
|
_handler = new CreateTipoDeIvaCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.InsertAsync(Arg.Any<TipoDeIva>(), Arg.Any<CancellationToken>()).Returns(42);
|
_repo.InsertAsync(Arg.Any<TipoDeIva>(), Arg.Any<CancellationToken>()).Returns(42);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class DeactivateTipoDeIvaCommandHandlerTests
|
|||||||
|
|
||||||
public DeactivateTipoDeIvaCommandHandlerTests()
|
public DeactivateTipoDeIvaCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new DeactivateTipoDeIvaCommandHandler(_repo, _audit);
|
_handler = new DeactivateTipoDeIvaCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
||||||
_repo.SetActivoAsync(Arg.Any<int>(), Arg.Any<bool>(), Arg.Any<CancellationToken>()).Returns(true);
|
_repo.SetActivoAsync(Arg.Any<int>(), Arg.Any<bool>(), Arg.Any<CancellationToken>()).Returns(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class NuevaVersionTipoDeIvaCommandHandlerTests
|
|||||||
|
|
||||||
public NuevaVersionTipoDeIvaCommandHandlerTests()
|
public NuevaVersionTipoDeIvaCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new NuevaVersionTipoDeIvaCommandHandler(_repo, _audit);
|
_handler = new NuevaVersionTipoDeIvaCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakePredecesora());
|
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakePredecesora());
|
||||||
_repo.UpdateCierreVigenciaAsync(Arg.Any<int>(), Arg.Any<DateOnly>(), Arg.Any<CancellationToken>())
|
_repo.UpdateCierreVigenciaAsync(Arg.Any<int>(), Arg.Any<DateOnly>(), Arg.Any<CancellationToken>())
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class ReactivateTipoDeIvaCommandHandlerTests
|
|||||||
|
|
||||||
public ReactivateTipoDeIvaCommandHandlerTests()
|
public ReactivateTipoDeIvaCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new ReactivateTipoDeIvaCommandHandler(_repo, _audit);
|
_handler = new ReactivateTipoDeIvaCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
||||||
_repo.SetActivoAsync(Arg.Any<int>(), Arg.Any<bool>(), Arg.Any<CancellationToken>()).Returns(true);
|
_repo.SetActivoAsync(Arg.Any<int>(), Arg.Any<bool>(), Arg.Any<CancellationToken>()).Returns(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class UpdateTipoDeIvaCommandHandlerTests
|
|||||||
|
|
||||||
public UpdateTipoDeIvaCommandHandlerTests()
|
public UpdateTipoDeIvaCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new UpdateTipoDeIvaCommandHandler(_repo, _audit);
|
_handler = new UpdateTipoDeIvaCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
_repo.GetByIdAsync(1, Arg.Any<CancellationToken>()).Returns(MakeEntity());
|
||||||
_repo.UpdateCosmeticoAsync(Arg.Any<int>(), Arg.Any<string>(), Arg.Any<string>(),
|
_repo.UpdateCosmeticoAsync(Arg.Any<int>(), Arg.Any<string>(), Arg.Any<string>(),
|
||||||
Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<CancellationToken>())
|
Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<CancellationToken>())
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class DeactivateUsuarioCommandHandlerTests
|
|||||||
|
|
||||||
public DeactivateUsuarioCommandHandlerTests()
|
public DeactivateUsuarioCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new DeactivateUsuarioCommandHandler(_repo, _refreshRepo, _audit);
|
_handler = new DeactivateUsuarioCommandHandler(_repo, _refreshRepo, _audit, TimeProvider.System);
|
||||||
_repo.CountActiveAdminsAsync(Arg.Any<CancellationToken>()).Returns(2);
|
_repo.CountActiveAdminsAsync(Arg.Any<CancellationToken>()).Returns(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class ReactivateUsuarioCommandHandlerTests
|
|||||||
|
|
||||||
public ReactivateUsuarioCommandHandlerTests()
|
public ReactivateUsuarioCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new ReactivateUsuarioCommandHandler(_repo, _audit);
|
_handler = new ReactivateUsuarioCommandHandler(_repo, _audit, TimeProvider.System);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Usuario MakeUser(int id = 5, bool activo = false)
|
private static Usuario MakeUser(int id = 5, bool activo = false)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class ResetUsuarioPasswordCommandHandlerTests
|
|||||||
|
|
||||||
public ResetUsuarioPasswordCommandHandlerTests()
|
public ResetUsuarioPasswordCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new ResetUsuarioPasswordCommandHandler(_repo, _hasher, _refreshRepo, _audit);
|
_handler = new ResetUsuarioPasswordCommandHandler(_repo, _hasher, _refreshRepo, _audit, TimeProvider.System);
|
||||||
_hasher.Hash(Arg.Any<string>()).Returns(args => "$2a$12$hashof_" + args[0]);
|
_hasher.Hash(Arg.Any<string>()).Returns(args => "$2a$12$hashof_" + args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class UpdateUsuarioCommandHandlerTests
|
|||||||
|
|
||||||
public UpdateUsuarioCommandHandlerTests()
|
public UpdateUsuarioCommandHandlerTests()
|
||||||
{
|
{
|
||||||
_handler = new UpdateUsuarioCommandHandler(_repo, _rolRepo, _refreshRepo, _audit);
|
_handler = new UpdateUsuarioCommandHandler(_repo, _rolRepo, _refreshRepo, _audit, TimeProvider.System);
|
||||||
|
|
||||||
// Default: rol exists and is active
|
// Default: rol exists and is active
|
||||||
_rolRepo.ExistsActiveByCodigoAsync(Arg.Any<string>(), Arg.Any<CancellationToken>()).Returns(true);
|
_rolRepo.ExistsActiveByCodigoAsync(Arg.Any<string>(), Arg.Any<CancellationToken>()).Returns(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user