public void TestGetTypeNotPresent() { RegisterPoolAndAssertion <TypeOne>(1); TypeTwo obj = PoolFactory.GetObject <TypeTwo>(); Assert.IsNull(obj); }
public void TestCreationAndGet() { RegisterPoolAndAssertion <TypeOne>(1, 10); TypeOne obj = PoolFactory.GetObject <TypeOne>(); Assert.IsNotNull(obj); }
public void TestCreatWithNoObjectsAndGet() { RegisterPoolAndAssertion <TypeOne>(1, 0); TypeOne obj = PoolFactory.GetObject <TypeOne>(); Assert.IsNotNull(obj); Assert.AreEqual(0, PoolFactory.GetPoolSize <TypeOne>()); PoolFactory.Recycle(ref obj); Assert.AreEqual(1, PoolFactory.GetPoolSize <TypeOne>()); }
public void TestRegisterOverload() { int toCompare = 55; TypeTwo toClone = new TypeTwo(toCompare); PoolFactory.RegisterPool(toClone, 2); TypeTwo obj = PoolFactory.GetObject <TypeTwo>(); Assert.IsNotNull(obj); Assert.AreEqual(toCompare, obj.testParam); }
public void TestRecycle() { RegisterPoolAndAssertion <TypeOne>(1); Assert.AreEqual(10, PoolFactory.GetPoolSize <TypeOne>()); TypeOne obj = PoolFactory.GetObject <TypeOne>(); Assert.AreEqual(9, PoolFactory.GetPoolSize <TypeOne>()); PoolFactory.Recycle(ref obj); Assert.AreEqual(10, PoolFactory.GetPoolSize <TypeOne>()); }
public void TestCompleteFlow() { PoolFactory.RegisterPool <TypeTwo>(); // Specify a value to have some instances of objects according to your needs PoolFactory.RegisterPool <TypeOne>(10); TypeOne obj_0 = PoolFactory.GetObject <TypeOne>(); // Use methods with "_E" if you want throw Exception TypeTwo obj_1 = PoolFactory.GetObject_E <TypeTwo>(); PoolFactory.Recycle(ref obj_0); }