public void Ctor_SetLockExpireAtWorks_WhenResourceIsNotLocked() { ConnectionUtils.UseConnection(database => { // Make a unique resource name so we do not conflict with others var resource = Guid.NewGuid().ToString(); var storageOption = new MongoStorageOptions { DistributedLockLifetime = TimeSpan.FromSeconds(3) }; using (new MongoDistributedLock(resource, TimeSpan.Zero, database, storageOption)) { DateTime initialExpireAt = DateTime.UtcNow; Thread.Sleep(TimeSpan.FromSeconds(5)); var filter = Builders <DistributedLockDto> .Filter.Eq(_ => _.Resource, resource); DistributedLockDto lockEntry = database.DistributedLock.Find(filter).FirstOrDefault(); Assert.NotNull(lockEntry); Assert.True(lockEntry.ExpireAt > initialExpireAt); } }); }