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

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

public class RetryPolicyTests
{
    [Fact]
    public void RetryPolicy_ShouldBeImmutableRecord()
    {
        var policy = new RetryPolicy(3, TimeSpan.FromSeconds(5));

        Assert.Equal(3, policy.MaxRetries);
        Assert.Equal(TimeSpan.FromSeconds(5), policy.Delay);
    }

    [Fact]
    public void RetryPolicy_WithExpression_ShouldCreateNewInstance()
    {
        var original = new RetryPolicy(3, TimeSpan.FromSeconds(5));
        var modified = original with { MaxRetries = 5 };

        Assert.Equal(3, original.MaxRetries);
        Assert.Equal(5, modified.MaxRetries);
        Assert.Equal(original.Delay, modified.Delay);
    }

    [Fact]
    public void RetryPolicy_EqualValues_ShouldBeEqual()
    {
        var a = new RetryPolicy(3, TimeSpan.FromSeconds(5));
        var b = new RetryPolicy(3, TimeSpan.FromSeconds(5));

        Assert.Equal(a, b);
    }
}
