using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;

namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Types;

public class EnumTests
{
    [Theory]
    [InlineData(typeof(DataType), new[] { "Boolean", "Int32", "Float", "Double", "String", "DateTime", "Binary", "List" })]
    [InlineData(typeof(InstanceState), new[] { "NotDeployed", "Enabled", "Disabled" })]
    [InlineData(typeof(DeploymentStatus), new[] { "Pending", "InProgress", "Success", "Failed" })]
    [InlineData(typeof(AlarmState), new[] { "Active", "Normal" })]
    [InlineData(typeof(AlarmLevel), new[] { "None", "Low", "LowLow", "High", "HighHigh" })]
    [InlineData(typeof(AlarmTriggerType), new[] { "ValueMatch", "RangeViolation", "RateOfChange", "HiLo", "Expression" })]
    [InlineData(typeof(ConnectionHealth), new[] { "Connected", "Disconnected", "Connecting", "Error" })]
    [InlineData(typeof(NotificationStatus), new[] { "Pending", "Retrying", "Delivered", "Parked", "Discarded" })]
    [InlineData(typeof(NotificationType), new[] { "Email", "Sms" })]
    public void Enum_ShouldHaveExpectedValues(Type enumType, string[] expectedNames)
    {
        var actualNames = Enum.GetNames(enumType);
        Assert.Equal(expectedNames, actualNames);
    }

    [Theory]
    [InlineData(typeof(DataType))]
    [InlineData(typeof(InstanceState))]
    [InlineData(typeof(DeploymentStatus))]
    [InlineData(typeof(AlarmState))]
    [InlineData(typeof(AlarmLevel))]
    [InlineData(typeof(AlarmTriggerType))]
    [InlineData(typeof(ConnectionHealth))]
    [InlineData(typeof(NotificationStatus))]
    [InlineData(typeof(NotificationType))]
    public void Enum_ShouldBeSingularNamed(Type enumType)
    {
        // Singular names should not end with 's' (except 'Status' which is singular)
        var name = enumType.Name;
        Assert.False(name.EndsWith("es") && !name.EndsWith("Status"),
            $"Enum {name} appears to be plural (ends with 'es').");
        Assert.False(name.EndsWith("s") && !name.EndsWith("ss") && !name.EndsWith("us"),
            $"Enum {name} appears to be plural (ends with 's').");
    }
}
