test(udt-011): TimeProvider Argentina extension tests with FakeTimeProvider (Red)
This commit is contained in:
@@ -0,0 +1,77 @@
|
|||||||
|
using FluentAssertions;
|
||||||
|
using Microsoft.Extensions.Time.Testing;
|
||||||
|
using SIGCM2.Application.Common;
|
||||||
|
|
||||||
|
namespace SIGCM2.Application.Tests.Common;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SUITE-BE-CLOCK — UDT-011 T300.10
|
||||||
|
/// Unit tests for TimeProviderArgentinaExtensions.GetArgentinaToday.
|
||||||
|
/// Uses FakeTimeProvider for deterministic UTC control.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class TimeProviderArgentinaExtensionsTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 22:30 ART del 30/04 = 01:30 UTC del 01/05.
|
||||||
|
/// UTC lleva al día siguiente, ART debe ser el día anterior.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void GetArgentinaToday_A22_30UTCdel01Mayo_Retorna30AbrilArgentina()
|
||||||
|
{
|
||||||
|
// 22:30 ART del 30/04 = 01:30 UTC del 01/05
|
||||||
|
var fake = new FakeTimeProvider();
|
||||||
|
fake.SetUtcNow(new DateTimeOffset(2026, 5, 1, 1, 30, 0, TimeSpan.Zero));
|
||||||
|
|
||||||
|
var result = fake.GetArgentinaToday();
|
||||||
|
|
||||||
|
result.Should().Be(new DateOnly(2026, 4, 30));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 00:30 ART del 01/05 = 03:30 UTC del 01/05.
|
||||||
|
/// Ambos UTC y ART son el mismo día civil.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void GetArgentinaToday_A00_30ARTdel01Mayo_Retorna01MayoArgentina()
|
||||||
|
{
|
||||||
|
// 00:30 ART del 01/05 = 03:30 UTC del 01/05
|
||||||
|
var fake = new FakeTimeProvider();
|
||||||
|
fake.SetUtcNow(new DateTimeOffset(2026, 5, 1, 3, 30, 0, TimeSpan.Zero));
|
||||||
|
|
||||||
|
var result = fake.GetArgentinaToday();
|
||||||
|
|
||||||
|
result.Should().Be(new DateOnly(2026, 5, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fin de mes en año bisiesto: 22:30 ART del 28/02/2024 = 01:30 UTC del 29/02/2024.
|
||||||
|
/// UTC cae en día bisiesto 29/02, ART debe devolver 28/02.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void GetArgentinaToday_BisiestoEnFinDeMesArgentina_RetornaCorrectoAR()
|
||||||
|
{
|
||||||
|
// 22:30 ART del 28/02/2024 (año bisiesto) = 01:30 UTC del 29/02/2024
|
||||||
|
var fake = new FakeTimeProvider();
|
||||||
|
fake.SetUtcNow(new DateTimeOffset(2024, 2, 29, 1, 30, 0, TimeSpan.Zero));
|
||||||
|
|
||||||
|
var result = fake.GetArgentinaToday();
|
||||||
|
|
||||||
|
result.Should().Be(new DateOnly(2024, 2, 28));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cruce de año: 22:30 ART del 31/12/2026 = 01:30 UTC del 01/01/2027.
|
||||||
|
/// UTC es año nuevo, ART debe ser el 31/12 del año anterior.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void GetArgentinaToday_FinDeAnio_22_30ARTdel31Dic_Retorna31Dic()
|
||||||
|
{
|
||||||
|
// 22:30 ART del 31/12/2026 = 01:30 UTC del 01/01/2027
|
||||||
|
var fake = new FakeTimeProvider();
|
||||||
|
fake.SetUtcNow(new DateTimeOffset(2027, 1, 1, 1, 30, 0, TimeSpan.Zero));
|
||||||
|
|
||||||
|
var result = fake.GetArgentinaToday();
|
||||||
|
|
||||||
|
result.Should().Be(new DateOnly(2026, 12, 31));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user