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:
2026-04-18 10:12:32 -03:00
parent a9838427a4
commit 9bc191c3ae
35 changed files with 79 additions and 75 deletions

View File

@@ -101,7 +101,7 @@ public class UsuarioTests
public void WithUpdatedProfile_Returns_NewInstance()
{
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);
}
@@ -109,7 +109,7 @@ public class UsuarioTests
public void WithUpdatedProfile_Sets_Fields_Correctly()
{
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("Gómez", updated.Apellido);
Assert.Equal("p@g.com", updated.Email);
@@ -121,8 +121,9 @@ public class UsuarioTests
public void WithUpdatedProfile_Sets_FechaModificacion_To_UtcNow()
{
var before = DateTime.UtcNow.AddSeconds(-1);
var now = DateTime.UtcNow;
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.True(updated.FechaModificacion >= before);
}
@@ -131,7 +132,7 @@ public class UsuarioTests
public void WithUpdatedProfile_Preserves_Immutable_Fields()
{
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.Username, updated.Username);
Assert.Equal(u.PasswordHash, updated.PasswordHash);
@@ -143,7 +144,7 @@ public class UsuarioTests
public void WithNewPasswordHash_Returns_NewInstance()
{
var u = MakeUsuario();
var updated = u.WithNewPasswordHash("newhash", mustChangePassword: false);
var updated = u.WithNewPasswordHash("newhash", mustChangePassword: false, DateTime.UtcNow);
Assert.NotSame(u, updated);
}
@@ -151,7 +152,7 @@ public class UsuarioTests
public void WithNewPasswordHash_Sets_Hash_And_MustChange()
{
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.True(updated.MustChangePassword);
}
@@ -160,7 +161,7 @@ public class UsuarioTests
public void WithNewPasswordHash_Clears_MustChange_When_False()
{
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);
}
@@ -168,8 +169,9 @@ public class UsuarioTests
public void WithNewPasswordHash_Sets_FechaModificacion()
{
var before = DateTime.UtcNow.AddSeconds(-1);
var now = DateTime.UtcNow;
var u = MakeUsuario();
var updated = u.WithNewPasswordHash("hash2", false);
var updated = u.WithNewPasswordHash("hash2", false, now);
Assert.NotNull(updated.FechaModificacion);
Assert.True(updated.FechaModificacion >= before);
}
@@ -208,7 +210,7 @@ public class UsuarioTests
public void WithMustChangePassword_Sets_Value_True()
{
var u = MakeUsuario(mustChangePassword: false);
var updated = u.WithMustChangePassword(true);
var updated = u.WithMustChangePassword(true, DateTime.UtcNow);
Assert.True(updated.MustChangePassword);
}
@@ -216,8 +218,9 @@ public class UsuarioTests
public void WithMustChangePassword_Sets_FechaModificacion()
{
var before = DateTime.UtcNow.AddSeconds(-1);
var now = DateTime.UtcNow;
var u = MakeUsuario();
var updated = u.WithMustChangePassword(true);
var updated = u.WithMustChangePassword(true, now);
Assert.NotNull(updated.FechaModificacion);
Assert.True(updated.FechaModificacion >= before);
}