public void TestPooling() { PoolFactory <object> factory = new PoolFactory <object>(10); // We allocate 10 objects ahead because a valid pool factory implementation could // decide to only start returning reused objects after the pool is full to quickly // grow the pool at the beginning. object[] objects = new object[10]; for (int index = 0; index < objects.Length; ++index) { objects[index] = factory.Take(); } for (int index = objects.Length - 1; index >= 0; --index) { factory.Redeem(objects[index]); } for (int index = 0; index < objects.Length; ++index) { Assert.Contains(factory.Take(), objects); } }
public void TestViaGenericFactoryInterface() { IAbstractFactory <object> factory = new PoolFactory <object>(10); Assert.IsNotNull(factory.CreateInstance()); }
public void TestExplicitConstructor() { PoolFactory <object> factory = new PoolFactory <object>(100); Assert.IsNotNull(factory); // Nonsense; prevents compiler warning }