public void ZeroCapacities() { var pool = new DefaultObjectPool <TestPooledObject>(() => new TestPooledObject(), 0, 0); var origLeased = pool.Lease(); pool.Return(origLeased); Assert.AreNotSame(origLeased, pool.Lease()); }
public void LeaseSetsReturnAction() { var pool = new DefaultObjectPool <TestPooledObject>(() => new TestPooledObject(), 10, 0); var origLeased = pool.Lease(); origLeased.ReturnAction(origLeased); pool.Dispose(); Assert.AreNotSame(origLeased, pool.Lease()); }
public void DisposeCleansSharedPool() { var pool = new DefaultObjectPool <TestPooledObject>(() => new TestPooledObject(), 10, 0); var origLeased = pool.Lease(); pool.Return(origLeased); pool.Dispose(); Assert.AreNotSame(origLeased, pool.Lease()); }
public void ObjectIsReused(int sharedCapacity, int threadLocalCapacity) { var pool = new DefaultObjectPool <TestPooledObject>(() => new TestPooledObject(), sharedCapacity, threadLocalCapacity); var origLeased = pool.Lease(); pool.Return(origLeased); Assert.AreSame(origLeased, pool.Lease()); Assert.AreNotSame(origLeased, pool.Lease()); }