public void Extension_throws_exception_when_used_with_invalid_expression()
        {
            var fixture = new TypePoolFixture();

            // Act
            string propertyName = fixture.GetPropertyName(p => p.IsEnabled && p.IsEnabled);

            // Assert
            Assert.AreEqual("CreationDate", propertyName);
        }
示例#2
0
        public void Get_properties_from_instance()
        {
            // Arrange
            var fixture = new TypePoolFixture();

            // Act
            IEnumerable<PropertyInfo> properties = PropertyCache.GetPropertiesForType(fixture);

            // Assert
            Assert.IsNotNull(properties);
        }
示例#3
0
        public void Get_properties_from_instance_with_predicate()
        {
            // Arrange
            var fixture = new TypePoolFixture();

            // Act
            IEnumerable<PropertyInfo> properties =
                PropertyCache.GetPropertiesForType(
                    fixture,
                    p => p.Name == fixture.GetPropertyName(pr => pr.IsEnabled));

            // Assert
            Assert.IsNotNull(properties);
        }
示例#4
0
        public void Get_properties_from_null_instance_throws_exception()
        {
            // Arrange
            var fixture = new TypePoolFixture();

            // Act
            IEnumerable<PropertyInfo> properties =
                PropertyCache.GetPropertiesForType<TypePoolFixture>(null, null);
        }
示例#5
0
        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>());
        }
示例#6
0
        public void Get_type_from_instance_returns_cached_type()
        {
            // Arrange
            var fixture = new TypePoolFixture();
            Type originalType = TypeCache.GetType(fixture);

            // Act
            Type cachedType = TypeCache.GetType(fixture);

            // Assert
            Assert.AreEqual(typeof(TypePoolFixture), cachedType);
            Assert.IsTrue(object.ReferenceEquals(originalType, cachedType), "The cached type was not returned.");
        }
示例#7
0
        public void Get_type_from_instance_returns_a_type()
        {
            // Arrange
            var fixture = new TypePoolFixture();

            // Act
            Type cachedType = TypeCache.GetType(fixture);

            // Assert
            Assert.AreEqual(typeof(TypePoolFixture), cachedType);
        }
示例#8
0
        public void Has_type_in_cache_returns_false_when_type_is_never_cached()
        {
            // Arrange
            var fixture = new TypePoolFixture();

            // Act
            bool exists = TypeCache.HasTypeInCache(fixture);

            // Assert
            Assert.IsFalse(exists);
        }
示例#9
0
        public void Has_type_in_cache_returns_true_when_type_is_cached()
        {
            // Arrange
            var fixture = new TypePoolFixture();
            TypeCache.AddType(typeof(TypePoolFixture));

            // Act
            bool exists = TypeCache.HasTypeInCache(fixture);

            // Assert
            Assert.IsTrue(exists);
        }