Files
KArtSell.Aegis/tests/KArtSell.ModelOperations.UnitTests/ModelOperationLeaseTests.cs
kjh2064 dcd1322d41
ci / backend (push) Failing after 12s
ci / frontend (push) Failing after 19s
ci / static (push) Failing after 45s
Initial commit: Add project files
2026-08-02 05:15:36 +09:00

14 lines
765 B
C#

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);
}
}