Exemplo n.º 1
0
        public void TestGetTypeNotPresent()
        {
            RegisterPoolAndAssertion <TypeOne>(1);
            TypeTwo obj = PoolFactory.GetObject <TypeTwo>();

            Assert.IsNull(obj);
        }
Exemplo n.º 2
0
        public void TestCreationAndGet()
        {
            RegisterPoolAndAssertion <TypeOne>(1, 10);

            TypeOne obj = PoolFactory.GetObject <TypeOne>();

            Assert.IsNotNull(obj);
        }
Exemplo n.º 3
0
        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>());
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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>());
        }
Exemplo n.º 6
0
        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);
        }