UDT-011: Localización Temporal Argentina (infra transversal) #25
@@ -67,6 +67,9 @@ public static class DependencyInjection
|
|||||||
{
|
{
|
||||||
public static IServiceCollection AddApplication(this IServiceCollection services)
|
public static IServiceCollection AddApplication(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
// UDT-011: TimeProvider singleton — available to all handlers for Cat2 date computation
|
||||||
|
services.AddSingleton(TimeProvider.System);
|
||||||
|
|
||||||
// Command handlers
|
// Command handlers
|
||||||
services.AddScoped<ICommandHandler<LoginCommand, LoginResponseDto>, LoginCommandHandler>();
|
services.AddScoped<ICommandHandler<LoginCommand, LoginResponseDto>, LoginCommandHandler>();
|
||||||
services.AddScoped<ICommandHandler<RefreshCommand, RefreshResponseDto>, RefreshCommandHandler>();
|
services.AddScoped<ICommandHandler<RefreshCommand, RefreshResponseDto>, RefreshCommandHandler>();
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using FluentAssertions;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using SIGCM2.Application;
|
||||||
|
|
||||||
|
namespace SIGCM2.Application.Tests.Common;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UDT-011 T300.20.2 — DI registration smoke tests for AddApplication.
|
||||||
|
/// Pure unit: no DB, no HTTP — just verifies the service container.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class AddApplicationDependencyInjectionTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// [REQ-BE-CLOCK-004] TimeProvider.System must be registered as singleton
|
||||||
|
/// so all command handlers can inject it without a concrete coupling.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void AddApplication_Registers_TimeProvider_System()
|
||||||
|
{
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
// AddApplication requires some infrastructure; provide minimal stubs
|
||||||
|
// by only testing the DI graph without building the full host.
|
||||||
|
services.AddApplication();
|
||||||
|
using var provider = services.BuildServiceProvider();
|
||||||
|
|
||||||
|
var timeProvider = provider.GetRequiredService<TimeProvider>();
|
||||||
|
|
||||||
|
timeProvider.Should().BeSameAs(TimeProvider.System);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user