public void PoolWithTxFunc()
        {
            var tokenSource = new CancellationTokenSource();
            var failure     = new AtomicReference <Exception>(null);

            var tasks = LaunchPoolWorkers(_driver, tokenSource.Token, worker => worker.RunWithTxFunc(), failure);

            Thread.Sleep(PoolTestDuration);
            tokenSource.Cancel();
            Task.WaitAll(tasks);

            failure.Get().Should().BeNull($"Some workers have failed. Exception {failure.Get()?.Message}");
        }
        public void PoolWithTxFuncWithFailingConnections()
        {
            var tokenSource = new CancellationTokenSource();
            var failure = new AtomicReference<Exception>(null);
            var (driver, connections) = SetupMonitoredDriver();

            var terminator = LaunchConnectionTerminator(connections, tokenSource.Token);
            var tasks = LaunchPoolWorkers(driver, tokenSource.Token, worker => worker.RunWithTxFunc(), failure);
            Thread.Sleep(PoolTestDuration);
            tokenSource.Cancel();
            Task.WaitAll(tasks.Union(new[] {terminator}).ToArray());

            failure.Get().Should().BeNull("no workers should fail");
        }