using Shared.Operations;
using Xunit;

namespace Shared.Operations.Tests;

public sealed class ReconcilePolicyTests
{
    [Fact]
    public void Equal_values_are_matched_immediately()
    {
        var now = DateTimeOffset.UtcNow;
        Assert.Equal("matched", ReconcilePolicy.DecideStatus(true, now, now, TimeSpan.FromSeconds(30)));
    }

    [Fact]
    public void Mismatch_inside_eventual_consistency_window_is_pending()
    {
        var changed = DateTimeOffset.UtcNow;
        Assert.Equal("pending", ReconcilePolicy.DecideStatus(false, changed, changed.AddSeconds(10), TimeSpan.FromSeconds(30)));
    }

    [Fact]
    public void Mismatch_after_grace_period_is_actionable()
    {
        var changed = DateTimeOffset.UtcNow;
        Assert.Equal("mismatch", ReconcilePolicy.DecideStatus(false, changed, changed.AddMinutes(2), TimeSpan.FromSeconds(30)));
    }
}
