using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Proxy.Supervisor;

namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Proxy.Tests;

[Trait("Category", "Unit")]
public sealed class BackoffTests
{
    [Fact]
    public void Default_sequence_is_5_15_60_seconds_capped()
    {
        var b = new Backoff();
        b.Next().ShouldBe(TimeSpan.FromSeconds(5));
        b.Next().ShouldBe(TimeSpan.FromSeconds(15));
        b.Next().ShouldBe(TimeSpan.FromSeconds(60));
        b.Next().ShouldBe(TimeSpan.FromSeconds(60), "capped once past the last entry");
    }

    [Fact]
    public void RecordStableRun_resets_to_the_first_delay()
    {
        var b = new Backoff();
        b.Next(); b.Next();
        b.RecordStableRun();
        b.Next().ShouldBe(TimeSpan.FromSeconds(5));
    }
}
