using ZB.MOM.WW.ScadaBridge.Commons.Types.Notifications;

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

public class SiteNotificationKpiSnapshotTests
{
    [Fact]
    public void Constructor_AssignsAllMembers()
    {
        var snapshot = new SiteNotificationKpiSnapshot(
            SourceSiteId: "plant-a",
            QueueDepth: 5,
            StuckCount: 2,
            ParkedCount: 1,
            DeliveredLastInterval: 40,
            OldestPendingAge: TimeSpan.FromMinutes(12));

        Assert.Equal("plant-a", snapshot.SourceSiteId);
        Assert.Equal(5, snapshot.QueueDepth);
        Assert.Equal(2, snapshot.StuckCount);
        Assert.Equal(1, snapshot.ParkedCount);
        Assert.Equal(40, snapshot.DeliveredLastInterval);
        Assert.Equal(TimeSpan.FromMinutes(12), snapshot.OldestPendingAge);
    }

    [Fact]
    public void OldestPendingAge_IsNullableForSitesWithNoBacklog()
    {
        var snapshot = new SiteNotificationKpiSnapshot("plant-b", 0, 0, 0, 0, null);
        Assert.Null(snapshot.OldestPendingAge);
    }
}
