using ZB.MOM.WW.ScadaBridge.Commons.Messages.DataConnection;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Alarms;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;

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

public class NativeAlarmMessagesTests
{
    [Fact]
    public void SubscribeAlarmsRequest_CarriesSourceAndFilter()
    {
        var r = new SubscribeAlarmsRequest("c1", "inst", "PlantOpcUa", "ns=2;s=Tank01", null, DateTimeOffset.UnixEpoch);
        Assert.Equal("ns=2;s=Tank01", r.SourceReference);
        Assert.Null(r.ConditionFilter);
    }

    [Fact]
    public void NativeAlarmTransitionUpdate_WrapsTransition()
    {
        var t = new NativeAlarmTransition("Tank01.Hi", "Tank01", "x", AlarmTransitionKind.Raise,
            new AlarmConditionState(true, false, null, AlarmShelveState.Unshelved, false, 500),
            "", "", "", "", "", null, DateTimeOffset.UnixEpoch, "", "");
        var u = new NativeAlarmTransitionUpdate("PlantOpcUa", t);
        Assert.Equal("PlantOpcUa", u.ConnectionName);
        Assert.Equal("Tank01", u.Transition.SourceObjectReference);
    }
}
