public void Disposing_pool_does_not_affect_busy_sockets() {
     var sockets = new List<FakeDisposableSocket>();
     Func<ISocket> socketFactory = () => {
         var socket = new FakeDisposableSocket();
         sockets.Add(socket);
         return socket;
     };
     var pool = new ConnectionPool(socketFactory);
     var s1 = pool.GetSocket();
     Assert.AreEqual(1, sockets.Count, "wrong number of sockets created");
     Assert.IsFalse(sockets[0].Disposed, "socket was disposed");
     pool.Dispose();
     Assert.IsFalse(sockets[0].Disposed, "socket was disposed");
     s1.Dispose();
 }
 public void Disposing_pool_cleans_up_sockets() {
     var sockets = new List<FakeDisposableSocket>();
     Func<ISocket> socketFactory = () => {
         var socket = new FakeDisposableSocket();
         sockets.Add(socket);
         return socket;
     };
     var pool = new ConnectionPool(socketFactory);
     var s1 = pool.GetSocket();
     var s2 = pool.GetSocket();
     s1.Dispose();
     s2.Dispose();
     Assert.AreEqual(2, sockets.Count, "wrong number of sockets created");
     Assert.IsFalse(sockets[0].Disposed, "first socket was disposed");
     Assert.IsFalse(sockets[1].Disposed, "second socket was disposed");
     pool.Dispose();
     Assert.IsTrue(sockets[0].Disposed, "first socket was not disposed");
     Assert.IsTrue(sockets[1].Disposed, "second socket was not disposed");
 }