Exemple #1
0
        public void PoolingGeneralTypesInfoGenerationTest()
        {
            PoolManager poolManager = new PoolManager();

            Assert.That(poolManager.PoolContents.Count == 0);
            Assert.That(poolManager.TypesSupportData.Count == 0);

            PoolSupportedObjectWithEvents poolSupportedObjectWithEvents =
                poolManager.GetObject <PoolSupportedObjectWithEvents>(typeof(PoolSupportedObjectWithEvents));

            Assert.That(poolManager.PoolContents.Count == 0);
            Assert.That(poolManager.TypesSupportData.Count == 1);
            Assert.That(poolManager.TypesSupportData.First().Key == poolSupportedObjectWithEvents.GetType());

            PoolSupportedObjectWithProperties poolSupportedObjectWithProperties =
                poolManager.GetObject <PoolSupportedObjectWithProperties>(typeof(PoolSupportedObjectWithProperties));

            Assert.That(poolManager.PoolContents.Count == 0);
            Assert.That(poolManager.TypesSupportData.Count == 2);

            poolSupportedObjectWithProperties.DisableAndSendToPool();
            poolSupportedObjectWithEvents.DisableAndSendToPool();

            Assert.That(poolManager.PoolContents.Count != 0);
            Assert.That(poolManager.TypesSupportData.Count == 2);
        }
Exemple #2
0
        public void PoolingGeneralObjectStorageTest()
        {
            PoolManager poolManager = new PoolManager();

            Assert.That(poolManager.PoolContents.Count == 0);

            PoolSupportedObjectWithEvents poolSupportedObjectWithEvents =
                poolManager.GetObject <PoolSupportedObjectWithEvents>(typeof(PoolSupportedObjectWithEvents));

            Assert.That(poolManager.PoolContents.Count == 0);

            PoolSupportedObjectWithFields poolSupportedObjectWithFields =
                poolManager.GetObject <PoolSupportedObjectWithFields>(typeof(PoolSupportedObjectWithFields));

            Assert.That(poolManager.PoolContents.Count == 0);

            PoolSupportedObjectWithProperties poolSupportedObjectWithProperties =
                poolManager.GetObject <PoolSupportedObjectWithProperties>(typeof(PoolSupportedObjectWithProperties));

            Assert.That(poolManager.PoolContents.Count == 0);

            poolSupportedObjectWithEvents.DisableAndSendToPool();

            Assert.That(poolManager.PoolContents.Count == 1);
            Assert.That(poolManager.PoolContents.First().Value.Count == 1);

            PoolSupportedObjectWithEvents poolSupportedObjectWithEventsDublicated =
                poolManager.GetObject <PoolSupportedObjectWithEvents>(typeof(PoolSupportedObjectWithEvents));

            Assert.That(poolManager.PoolContents.First().Value.Count == 0);
            Assert.AreEqual(poolSupportedObjectWithEvents, poolSupportedObjectWithEventsDublicated);

            poolSupportedObjectWithFields.DisableAndSendToPool();
            poolSupportedObjectWithProperties.DisableAndSendToPool();

            Assert.That(poolManager.PoolContents.Count == 3);

            int objectsOperationsCount = 100;

            PoolSupportedObject[] supportedObjects = new PoolSupportedObject[objectsOperationsCount];

            for (int i = 0; i < objectsOperationsCount; i++)
            {
                supportedObjects[i] = poolManager.GetObject <PoolSupportedObject>(typeof(PoolSupportedObjectWithEvents));
                supportedObjects[i].DisableAndSendToPool();
            }

            Assert.That(poolManager.PoolContents.First().Value.Count == 1);
        }
Exemple #3
0
        public void PropertiesCleanupTest()
        {
            PoolManager poolManager = new PoolManager();

            PoolSupportedObjectWithProperties poolSupportedObjectWithProperties =
                poolManager.GetObject <PoolSupportedObjectWithProperties>(typeof(PoolSupportedObjectWithProperties));

            poolSupportedObjectWithProperties.Init();

            Assert.That(!poolSupportedObjectWithProperties.IsEverythingDefault());

            poolSupportedObjectWithProperties.DisableAndSendToPool();

            Assert.That(poolSupportedObjectWithProperties.IsEverythingDefault());
        }