public void GetConnection_ReturnsCorrectResult() { var options = new EFCoreStorageOptions(); var instance = new EFCoreStorage(OptionsAction, options); var result = instance.GetConnection(); Assert.NotNull(result); var connection = Assert.IsType <EFCoreStorageConnection>(result); Assert.Same(instance, Assert.IsType <EFCoreStorage>( connection.GetFieldValue("_storage"))); }
private void UseLock(Action action) { var lockTimeout = _storage.DistributedLockTimeout; using var connection = _storage.GetConnection(); try { using (connection.AcquireDistributedLock(LockKey, lockTimeout)) action.Invoke(); } catch (DistributedLockTimeoutException exception) when(exception.Resource == LockKey) { _logger.Log(LogLevel.Debug, () => CoreStrings.ExpirationManagerUseLockFailed( LockKey, lockTimeout.TotalSeconds, _storage.JobExpirationCheckInterval.TotalSeconds), exception); } }