public async Task ReleaseDecreasesCount()
        {
            var manager = new SessionPoolManager(new SessionPoolOptions(), Logger.DefaultLogger, FailingSpannerClient.Factory);

            var options = new SpannerClientCreationOptions(new SpannerConnectionStringBuilder(ConnectionString));
            var pool    = await manager.AcquireSessionPoolAsync(options);

            var stats = manager.GetStatistics().Single();

            Assert.Equal(1, stats.ActiveConnectionCount);

            manager.Release(pool);

            stats = manager.GetStatistics().Single();
            Assert.Equal(0, stats.ActiveConnectionCount);
        }
        public async Task EqualOptions_SameSessionPool()
        {
            int           factoryCalls = 0;
            ClientFactory factory      = (options, settings, logger) =>
            {
                factoryCalls++;
                return(Task.FromResult <SpannerClient>(new FailingSpannerClient()));
            };
            var manager = new SessionPoolManager(new SessionPoolOptions(), Logger.DefaultLogger, factory);

            var options1 = new SpannerClientCreationOptions(new SpannerConnectionStringBuilder(ConnectionString));
            var options2 = new SpannerClientCreationOptions(new SpannerConnectionStringBuilder(ConnectionString));

            var pool1 = await manager.AcquireSessionPoolAsync(options1);

            var pool2 = await manager.AcquireSessionPoolAsync(options2);

            Assert.Same(pool1, pool2);
            Assert.Equal(1, factoryCalls);
            Assert.Equal(1, manager.GetStatistics().Count);
        }
        public async Task DifferentOptions_DifferentSessionPools()
        {
            int           factoryCalls = 0;
            ClientFactory factory      = options =>
            {
                factoryCalls++;
                return(Task.FromResult <SpannerClient>(new FailingSpannerClient()));
            };
            var manager = new SessionPoolManager(new SessionPoolOptions(), Logger.DefaultLogger, factory);

            var options1 = new SpannerClientCreationOptions(new SpannerConnectionStringBuilder(ConnectionString));
            var options2 = new SpannerClientCreationOptions(new SpannerConnectionStringBuilder(ConnectionString)
            {
                Port = 1234
            });

            var pool1 = await manager.AcquireSessionPoolAsync(options1);

            var pool2 = await manager.AcquireSessionPoolAsync(options2);

            Assert.NotSame(pool1, pool2);
            Assert.Equal(2, factoryCalls);
            Assert.Equal(2, manager.GetStatistics().Count);
        }