using KArtSell.Modules.ModelOperations.Domain;
namespace KArtSell.ModelOperations.UnitTests;
public sealed class ModelOperationLeaseTests
{
    [Fact] public void Stale_token_cannot_renew() {
        var now=DateTimeOffset.UtcNow; var lease=new ModelOperationLease("J42","GLOBAL",new LeaseFencingToken(3),"worker-a",now.AddMinutes(5));
        Assert.Throws<InvalidOperationException>(()=>lease.Renew(new LeaseFencingToken(2),"worker-a",now.AddMinutes(10)));
    }
    [Fact] public void Expired_lease_transfer_increments_token() {
        var now=DateTimeOffset.UtcNow; var lease=new ModelOperationLease("J42","GLOBAL",new LeaseFencingToken(3),"worker-a",now.AddMinutes(-1));
        Assert.Equal(4,lease.Transfer(now,"worker-b",now.AddMinutes(5)).Value);
    }
}
