public EagerPoolTest() { var calls = 0; MockInnerPool.Setup(inner => inner.Size).Returns(2); MockInnerPool.Setup(inner => inner.Return("x")).Callback(() => calls++).Returns(true); DecoratedPool = new EagerPool <string>(MockInnerPool.Object, CreateFactory, ReleaseFactory); Assert.Equal(2, calls); }
public void TestPoolingEagerAndFifo() { // FIX: Reset global count due other tests running before Foo.GlobalCount = 0; using (var pool = new EagerPool <Foo>(PoolSize, p => new Foo(p))) { // All foo's sould be created and raised the number Assert.True(Foo.GlobalCount == PoolSize); // Fetch 2 objects var foo = pool.Acquire(); var foo2 = pool.Acquire(); // They should be initialized Assert.True(foo != null); Assert.True(foo2 != null); // Realease them - also in the pool foo.Dispose(); foo2.Dispose(); } }
public void TestPoolingEagerAndFifo() { // FIX: Reset global count due other tests running before Foo.GlobalCount = 0; using (var pool = new EagerPool<Foo>(PoolSize, p => new Foo(p))) { // All foo's sould be created and raised the number Assert.True(Foo.GlobalCount == PoolSize); // Fetch 2 objects var foo = pool.Acquire(); var foo2 = pool.Acquire(); // They should be initialized Assert.True(foo != null); Assert.True(foo2 != null); // Realease them - also in the pool foo.Dispose(); foo2.Dispose(); } }