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

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

public class AlarmConditionStateTests
{
    [Fact]
    public void AlarmConditionState_DefaultsAreNormalUnshelved()
    {
        var s = new AlarmConditionState(
            Active: false, Acknowledged: true, Confirmed: null,
            Shelve: AlarmShelveState.Unshelved, Suppressed: false, Severity: 0);

        Assert.False(s.Active);
        Assert.Equal(AlarmShelveState.Unshelved, s.Shelve);
        Assert.Equal(0, s.Severity);
    }

    [Fact]
    public void NativeAlarmTransition_CarriesSourceAndCondition()
    {
        var t = new NativeAlarmTransition(
            SourceReference: "Tank01.Level.HiHi", SourceObjectReference: "Tank01",
            AlarmTypeName: "AnalogLimitAlarm.HiHi", Kind: AlarmTransitionKind.Raise,
            Condition: new AlarmConditionState(true, false, null, AlarmShelveState.Unshelved, false, 800),
            Category: "Process", Description: "High level", Message: "level high",
            OperatorUser: "", OperatorComment: "",
            OriginalRaiseTime: null, TransitionTime: DateTimeOffset.UnixEpoch,
            CurrentValue: "92.1", LimitValue: "90");

        Assert.Equal("Tank01", t.SourceObjectReference);
        Assert.Equal(800, t.Condition.Severity);
        Assert.Equal(AlarmTransitionKind.Raise, t.Kind);
    }
}
