using Shouldly;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
using Xunit;

namespace ZB.MOM.WW.OtOpcUa.Core.Abstractions.Tests;

public class AlarmEventArgsTests
{
    private static AlarmEventArgs Make(AlarmTransitionKind? kind = null) =>
        kind is null
            ? new AlarmEventArgs(new FakeHandle(), "Tank1.Hi", "c1", "LimitAlarm.Hi", "msg", AlarmSeverity.High, DateTime.UnixEpoch)
            : new AlarmEventArgs(new FakeHandle(), "Tank1.Hi", "c1", "LimitAlarm.Hi", "msg", AlarmSeverity.High, DateTime.UnixEpoch, Kind: kind.Value);

    [Fact]
    public void Kind_defaults_to_Unspecified_so_existing_callers_compile()
        => Make().Kind.ShouldBe(AlarmTransitionKind.Unspecified);

    [Fact]
    public void Kind_round_trips_when_supplied()
        => Make(AlarmTransitionKind.Raise).Kind.ShouldBe(AlarmTransitionKind.Raise);

    private sealed class FakeHandle : IAlarmSubscriptionHandle { public string DiagnosticId => "t"; }
}
