using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Flattening;

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

public class NativeAlarmSourceEntityTests
{
    [Fact]
    public void TemplateNativeAlarmSource_RequiresName()
    {
        var s = new TemplateNativeAlarmSource("PressureMon") { ConnectionName = "Plant", SourceReference = "ns=2;s=P1" };
        Assert.Equal("PressureMon", s.Name);
        Assert.False(s.IsLocked);
    }

    [Fact]
    public void FlattenedConfiguration_HasNativeAlarmSourcesDefaultEmpty()
    {
        var f = new FlattenedConfiguration();
        Assert.Empty(f.NativeAlarmSources);
    }

    [Fact]
    public void ResolvedNativeAlarmSource_DefaultsSourceTemplate()
    {
        var r = new ResolvedNativeAlarmSource { CanonicalName = "PressureMon", ConnectionName = "Plant", SourceReference = "ns=2;s=P1" };
        Assert.Equal("Template", r.Source);
    }
}
