using SolutionErp.Application.Common.Interfaces;

namespace SolutionErp.Infrastructure.Tests.Common;

// Stub ICurrentUser cho tests cần inject ChangelogService (Contract V2 wire S29).
// ChangelogService resolve actor qua ICurrentUser.UserId → cần stub
// configurable per test scenario (vd BW3 admin bypass cần Roles chứa "Admin").
//
// Pattern: instance per test, set Acting* properties trước khi gọi service.
// Khác ICurrentUser prod (HttpContextCurrentUser) đọc JWT claims — test
// override trực tiếp.
public sealed class TestCurrentUser : ICurrentUser
{
    public Guid? UserId { get; set; }
    public string? Email { get; set; }
    public string? FullName { get; set; }
    public IReadOnlyList<string> Roles { get; set; } = Array.Empty<string>();
    public bool IsAuthenticated => UserId is not null;

    public TestCurrentUser() { }

    public TestCurrentUser(Guid userId, string? fullName = null, string? email = null, params string[] roles)
    {
        UserId = userId;
        FullName = fullName;
        Email = email;
        Roles = roles ?? Array.Empty<string>();
    }

    // Helper: simulate system actor (vd SLA auto-approve, DbInitializer seed).
    public static TestCurrentUser System() => new();
}
