using System.Security.Claims;
using ChatService.API.Hubs;
using FluentAssertions;
using Microsoft.AspNetCore.SignalR;
using Xunit;

namespace ChatService.UnitTests.Application.Hubs;

/// <summary>
/// EN: Unit tests for ClaimsUserIdProvider.
/// VI: Unit tests cho ClaimsUserIdProvider.
/// </summary>
public class ClaimsUserIdProviderTests
{
    private readonly ClaimsUserIdProvider _sut;

    public ClaimsUserIdProviderTests()
    {
        _sut = new ClaimsUserIdProvider();
    }

    [Fact]
    public void ClaimsUserIdProvider_ShouldImplementIUserIdProvider()
    {
        // Assert
        _sut.Should().BeAssignableTo<IUserIdProvider>();
    }

    [Theory]
    [InlineData(ClaimTypes.NameIdentifier)]
    [InlineData("sub")]
    [InlineData("user_id")]
    public void GetUserId_ShouldSupportMultipleClaimTypes(string claimType)
    {
        // EN: This verifies the expected claim types are documented
        // VI: Kiểm tra các claim types được hỗ trợ đã được ghi nhận
        var supportedClaimTypes = new[] { ClaimTypes.NameIdentifier, "sub", "user_id" };
        supportedClaimTypes.Should().Contain(claimType);
    }

    [Fact]
    public void ClaimsUserIdProvider_ShouldNotBeNull()
    {
        // Assert
        _sut.Should().NotBeNull();
    }
}
