public async Task Should_aquire_on_renew_when_expired()
        {
            var nowUtc = DateTime.UtcNow;
            SqlServerSemaphore sema = new SqlServerSemaphore(ConnectionString, _semaphoreName, 2, 1);
            var owner1Res           = await sema.TryAcquire(_ownerId1);

            owner1Res.ShouldBeTrue();

            await Task.Delay(2500);

            var semaInfo = await sema.GetSemaphoreInfo();

            var owners = sema.Deserialize(semaInfo.OwnersJson);
            var owner1 = owners.Owners.Single(x => x.OwnerId == _ownerId1);

            owner1.ExpiresAtUtc.ShouldBeLessThan(DateTime.UtcNow);

            var renewNow       = DateTime.UtcNow;
            var owner1RenewRes = await sema.TryRenew(_ownerId1);

            owner1RenewRes.ShouldBeTrue();

            semaInfo = await sema.GetSemaphoreInfo();

            owners = sema.Deserialize(semaInfo.OwnersJson);
            owner1 = owners.Owners.Single(x => x.OwnerId == _ownerId1);
            owner1.ExpiresAtUtc.ShouldBeGreaterThan(renewNow);
        }
        public async Task Should_aquire_on_renew_when_not_owner()
        {
            var nowUtc = DateTime.UtcNow;
            SqlServerSemaphore sema = new SqlServerSemaphore(ConnectionString, _semaphoreName, 20, 1);
            var owner1Res           = await sema.TryRenew(_ownerId1);

            owner1Res.ShouldBeTrue();

            var semaInfo = await sema.GetSemaphoreInfo();

            var owners = sema.Deserialize(semaInfo.OwnersJson);

            owners.Owners.Count.ShouldBe(1);
            var owner1 = owners.Owners.Single(x => x.OwnerId == _ownerId1);

            owner1.ExpiresAtUtc.ShouldBeGreaterThan(DateTime.UtcNow);
        }
        public async Task Should_renew()
        {
            SqlServerSemaphore sema = new SqlServerSemaphore(ConnectionString, _semaphoreName, 10, 5);
            var owner1Res           = await sema.TryAcquire(_ownerId1);

            var owner2Res = await sema.TryAcquire(_ownerId2);

            var owner3Res = await sema.TryAcquire(_ownerId3);

            var owner4Res = await sema.TryAcquire(_ownerId4);

            var owner5Res = await sema.TryAcquire(_ownerId5);

            var owner6Res = await sema.TryAcquire(_ownerId6);

            owner1Res.ShouldBeTrue();
            owner2Res.ShouldBeTrue();
            owner3Res.ShouldBeTrue();
            owner4Res.ShouldBeTrue();
            owner5Res.ShouldBeTrue();
            owner6Res.ShouldBeFalse();

            await Task.Delay(5000);

            var nowUtc         = DateTime.UtcNow;
            var owner1RenewRes = await sema.TryRenew(_ownerId1);

            var owner2RenewRes = await sema.TryRenew(_ownerId2);

            var owner3RenewRes = await sema.TryRenew(_ownerId3);

            var owner4RenewRes = await sema.TryRenew(_ownerId4);

            var owner5RenewRes = await sema.TryRenew(_ownerId5);

            var owner6RenewRes = await sema.TryRenew(_ownerId6);

            owner1RenewRes.ShouldBeTrue();
            owner2RenewRes.ShouldBeTrue();
            owner3RenewRes.ShouldBeTrue();
            owner4RenewRes.ShouldBeTrue();
            owner5RenewRes.ShouldBeTrue();
            owner6RenewRes.ShouldBeFalse();

            var semaInfo = await sema.GetSemaphoreInfo();

            var owners = sema.Deserialize(semaInfo.OwnersJson);

            owners.Owners.Count().ShouldBe(5);

            var owner1 = owners.Owners.Single(x => x.OwnerId == _ownerId1);

            owner1.ExpiresAtUtc.ShouldBeInRange(nowUtc.AddSeconds(9), nowUtc.AddSeconds(13));

            var owner2 = owners.Owners.Single(x => x.OwnerId == _ownerId2);

            owner2.ExpiresAtUtc.ShouldBeInRange(nowUtc.AddSeconds(9), nowUtc.AddSeconds(13));

            var owner3 = owners.Owners.Single(x => x.OwnerId == _ownerId3);

            owner3.ExpiresAtUtc.ShouldBeInRange(nowUtc.AddSeconds(9), nowUtc.AddSeconds(13));

            var owner4 = owners.Owners.Single(x => x.OwnerId == _ownerId4);

            owner4.ExpiresAtUtc.ShouldBeInRange(nowUtc.AddSeconds(9), nowUtc.AddSeconds(13));

            var owner5 = owners.Owners.Single(x => x.OwnerId == _ownerId5);

            owner5.ExpiresAtUtc.ShouldBeInRange(nowUtc.AddSeconds(9), nowUtc.AddSeconds(13));
        }