public async Task CreateConnectionStringBasedPool() { PoolFactory.InitializeNamedPool <TestPoolWithConnectionString>(2, null); var item1 = PoolFactory.Create <TestPoolWithConnectionString>("http://test1.com/mongo"); var item2 = PoolFactory.Create <TestPoolWithConnectionString>("http://test2.com/mongo"); var item3 = PoolFactory.Create <TestPoolWithConnectionString>("http://test1.com/mongo"); var item4 = PoolFactory.Create <TestPoolWithConnectionString>("http://test2.com/mongo"); Assert.AreNotEqual(item1, item2); Assert.AreNotEqual(item3, item4); Assert.AreNotEqual(item1, item3); Assert.AreNotEqual(item2, item3); Assert.AreNotEqual(item1, item4); try { var item = PoolFactory.Create <TestPoolWithConnectionString>("http://test1.com/mongo"); Assert.Fail(); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(Exception)); } var itemTask = Task.Run(() => PoolFactory.CreateAsync <TestPoolWithConnectionString>("http://test1.com/mongo")); item1.Dispose(); await Task.Delay(1); var item5 = await itemTask.ConfigureAwait(false); item2.Dispose(); item3.Dispose(); item4.Dispose(); item5.Dispose(); try { PoolFactory.DisposeNamedPool <TestPoolWithConnectionString>(); } catch { } }