public void Performance_test_get_properties_for_type_without_cache_using_predicate()
        {
            // Arrange
            // Pre-load all of the Types so we can test against a Pool containing existing objects.
            IEnumerable <Type> types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes());

            types.AsParallel().ForAll(type => PropertyCache.GetPropertiesForType(type));
            const int _iterations = 1000;
            var       times       = new List <double>();


            // Act
            for (int count = 0; count < _iterations; count++)
            {
                TypeCache.ClearTypeFromPool <TypePoolFixture>();
                var timer = new Stopwatch();
                timer.Start();
                IEnumerable <PropertyInfo> results =
                    PropertyCache.GetPropertiesForType <TypePoolFixture>(info => Attribute.IsDefined(info, typeof(AttributeFixture)));
                timer.Stop();
                times.Add(timer.Elapsed.TotalMilliseconds);
            }

            Debug.WriteLine($"The average time to fetch an uncached collection of filtered properties over {_iterations} iterations was {times.Sum() / times.Count}ms");
        }
        public void Performance_test_get_properties_for_type_without_cache_from_large_cache_pool()
        {
            // Arrange
            // Pre-load all of the Types so we can test against a Pool containing existing objects.
            IEnumerable <Type> types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes());

            types.AsParallel().ForAll(type => PropertyCache.GetPropertiesForType(type));
            const int _iterations = 1000;
            var       times       = new List <double>();

            // Act
            for (int count = 0; count < _iterations; count++)
            {
                // Remove PayItem so we can test it not existing in the Pool.
                TypeCache.ClearTypeFromPool <TypePoolFixture>();

                var timer = new Stopwatch();
                timer.Start();
                var results = PropertyCache.GetPropertiesForType <TypePoolFixture>();
                timer.Stop();
                times.Add(timer.Elapsed.TotalMilliseconds);
            }

            Debug.WriteLine($"The average time to fetch an uncached collection properties from a large pool over {_iterations} iterations was {times.Sum() / times.Count}ms");
        }
        public void Remove_type_from_pool_without_cache()
        {
            // Act
            TypeCache.ClearTypeFromPool <ComponentFixture>();

            // Assert
            Assert.IsFalse(TypeCache.HasTypeInCache <ComponentFixture>());
        }
        public void Remove_type_from_pool_with_existing_cache()
        {
            // Arrange
            PropertyCache.GetPropertiesForType(typeof(ComponentFixture));

            // Act
            TypeCache.ClearTypeFromPool <ComponentFixture>();

            // Assert
            Assert.IsFalse(TypeCache.HasTypeInCache <ComponentFixture>());
        }
        public void Clear_type_from_pool_clears_cache()
        {
            // Arrange
            var fixture = new TypePoolFixture();

            TypeCache.AddType(typeof(TypePoolFixture));

            // Act
            TypeCache.ClearTypeFromPool(fixture);

            // Assert
            Assert.IsFalse(TypeCache.HasTypeInCache <TypePoolFixture>());
        }
 public void Clear_type_from_pool_with_null_instance_throws_exception()
 {
     // Act
     TypeCache.ClearTypeFromPool(null);
 }