feat(adm-009): TipoDeIvaRepository + IngresosBrutosRepository Dapper implementations + DI registration
This commit is contained in:
@@ -24,13 +24,21 @@ public class IngresosBrutosRepositoryTests : IAsyncLifetime
|
||||
private SqlConnection _connection = null!;
|
||||
private IIngresosBrutosRepository _repo = null!;
|
||||
|
||||
private static readonly int _runBase;
|
||||
|
||||
static IngresosBrutosRepositoryTests()
|
||||
{
|
||||
var bytes = Guid.NewGuid().ToByteArray();
|
||||
_runBase = (int)(BitConverter.ToUInt32(bytes, 0) % 500_000u);
|
||||
}
|
||||
|
||||
private static int _testCounter = 0;
|
||||
|
||||
private static DateOnly NextUniqueDate()
|
||||
{
|
||||
var counter = Interlocked.Increment(ref _testCounter);
|
||||
// Start at 2091-01-01 to avoid clashing with TipoDeIvaRepositoryTests (2090-01-01)
|
||||
return new DateOnly(2091, 1, 1).AddDays(counter);
|
||||
// Base year 2091 (different from TipoDeIvaRepositoryTests which uses 2090).
|
||||
return new DateOnly(2091, 1, 1).AddDays(_runBase + counter);
|
||||
}
|
||||
|
||||
public async Task InitializeAsync()
|
||||
|
||||
@@ -25,15 +25,26 @@ public class TipoDeIvaRepositoryTests : IAsyncLifetime
|
||||
private SqlConnection _connection = null!;
|
||||
private ITipoDeIvaRepository _repo = null!;
|
||||
|
||||
// Use a unique date range for this test class to avoid UQ constraint clashes with seed
|
||||
// seed uses VigenciaDesde = '2020-01-01'; we use a far-future range per test.
|
||||
// TipoDeIva rows are never Respawned (seed data). We need a globally unique VigenciaDesde
|
||||
// per (Codigo, VigenciaDesde) pair across all test runs.
|
||||
// Strategy: derive a large pseudo-random day offset from a Guid generated once per
|
||||
// process + an Interlocked counter for intra-run uniqueness.
|
||||
// This makes the probability of collision between runs astronomically small.
|
||||
private static readonly int _runBase;
|
||||
|
||||
static TipoDeIvaRepositoryTests()
|
||||
{
|
||||
// Take the first 4 bytes of a fresh Guid as a pseudo-random int in [0, 500_000)
|
||||
var bytes = Guid.NewGuid().ToByteArray();
|
||||
_runBase = (int)(BitConverter.ToUInt32(bytes, 0) % 500_000u);
|
||||
}
|
||||
|
||||
private static int _testCounter = 0;
|
||||
|
||||
private static DateOnly NextUniqueDate()
|
||||
{
|
||||
var counter = Interlocked.Increment(ref _testCounter);
|
||||
// Start at 2090-01-01 + counter days so each test gets its own unique date
|
||||
return new DateOnly(2090, 1, 1).AddDays(counter);
|
||||
return new DateOnly(2090, 1, 1).AddDays(_runBase + counter);
|
||||
}
|
||||
|
||||
public async Task InitializeAsync()
|
||||
|
||||
Reference in New Issue
Block a user