private static async Task RunTest <TKey, TObject>(Func <OperationContext, ResourcePoolV2 <TKey, TObject>, Task> func, Func <TKey, TObject> factory, ResourcePoolConfiguration?configuration = null, IClock?clock = null) where TKey : notnull where TObject : IStartupShutdownSlim { configuration ??= new ResourcePoolConfiguration(); var tracingContext = new Context(TestGlobal.Logger); var context = new OperationContext(tracingContext); var pool = new ResourcePoolV2 <TKey, TObject>(tracingContext, configuration, factory, clock); try { await func(context, pool); } finally { pool.Dispose(); ValidateCounters(pool.Counter); } }
/// <inheritdoc /> public void Dispose() { _resourcePool?.Dispose(); _resourcePoolV2?.Dispose(); }