using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Driver.AbCip;

namespace ZB.MOM.WW.OtOpcUa.Driver.AbCip.IntegrationTests;

/// <summary>
///     Pure-unit tests for the profile catalog. Verifies <see cref="KnownProfiles"/>
///     stays in sync with <see cref="AbCipPlcFamily"/> + with the compose-file service
///     names — a typo in either would surface as a test failure rather than a silent
///     "wrong family booted" at runtime. Runs without Docker, so CI without the
///     container still exercises these contracts.
/// </summary>
[Trait("Category", "Unit")]
public sealed class AbServerProfileTests
{
    /// <summary>Verifies known profiles for family returns expected compose profile.</summary>
    /// <param name="family">The AB CIP PLC family.</param>
    /// <param name="expected">The expected Docker Compose profile name.</param>
    [Theory]
    [InlineData(AbCipPlcFamily.ControlLogix, "controllogix")]
    [InlineData(AbCipPlcFamily.CompactLogix, "compactlogix")]
    [InlineData(AbCipPlcFamily.Micro800,     "micro800")]
    [InlineData(AbCipPlcFamily.GuardLogix,   "guardlogix")]
    public void KnownProfiles_ForFamily_Returns_Expected_ComposeProfile(AbCipPlcFamily family, string expected)
    {
        KnownProfiles.ForFamily(family).ComposeProfile.ShouldBe(expected);
    }

    /// <summary>Verifies known profiles all covers every family.</summary>
    [Fact]
    public void KnownProfiles_All_Covers_Every_Family()
    {
        var covered = KnownProfiles.All.Select(p => p.Family).ToHashSet();
        foreach (var family in Enum.GetValues<AbCipPlcFamily>())
            covered.ShouldContain(family, $"Family {family} is missing a KnownProfiles entry.");
    }

    /// <summary>Verifies default port matches EtherNetIP standard.</summary>
    [Fact]
    public void DefaultPort_Matches_EtherNetIP_Standard()
    {
        AbServerProfile.DefaultPort.ShouldBe(44818);
    }
}
