using ScadaLink.Commons.Types.Enums;

namespace ScadaLink.Commons.Tests.Types;

public class EnumTests
{
    [Theory]
    [InlineData(typeof(DataType), new[] { "Boolean", "Int32", "Float", "Double", "String", "DateTime", "Binary" })]
    [InlineData(typeof(InstanceState), new[] { "NotDeployed", "Enabled", "Disabled" })]
    [InlineData(typeof(DeploymentStatus), new[] { "Pending", "InProgress", "Success", "Failed" })]
    [InlineData(typeof(AlarmState), new[] { "Active", "Normal" })]
    [InlineData(typeof(AlarmTriggerType), new[] { "ValueMatch", "RangeViolation", "RateOfChange" })]
    [InlineData(typeof(ConnectionHealth), new[] { "Connected", "Disconnected", "Connecting", "Error" })]
    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(AlarmTriggerType))]
    [InlineData(typeof(ConnectionHealth))]
    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').");
    }
}
