示例#1
0
        public void HasPublicSetter_ReturnsFalseIfGetterDoesNotExistOrIsNonPublic(string propertyName)
        {
            // Arrange
            var property            = GetPropertyInfo(propertyName);
            var runtimePropertyInfo = new RuntimePropertyInfo(property);

            // Act
            var result = runtimePropertyInfo.HasPublicSetter;

            // Assert
            Assert.False(result);
        }
示例#2
0
        public void HasPublicSetter_ReturnsTrueIfSetterExistsAndIsPublic(string propertyName)
        {
            // Arrange
            var property            = GetPropertyInfo(propertyName);
            var runtimePropertyInfo = new RuntimePropertyInfo(property);

            // Act
            var result = runtimePropertyInfo.HasPublicSetter;

            // Assert
            Assert.True(result);
        }
示例#3
0
        public void GetAttributes_DoesNotInheritAttributes()
        {
            // Arrange
            var property        = GetPropertyInfo(nameof(TestType.PropertyWithAttributes));
            var runtimeProperty = new RuntimePropertyInfo(property);

            // Act
            var attributes = property.GetCustomAttributes <HtmlAttributeNotBoundAttribute>();

            // Assert
            Assert.Empty(attributes);
        }
示例#4
0
        public void GetAttributes_ReturnsCustomAttributesOfSpecifiedType()
        {
            // Arrange
            var property        = GetPropertyInfo(nameof(TestType.PropertyWithAttributes));
            var runtimeProperty = new RuntimePropertyInfo(property);

            // Act
            var attributes = property.GetCustomAttributes <HtmlAttributeNameAttribute>();

            // Assert
            var htmlAttributeName = Assert.Single(attributes);

            Assert.Equal("somename", htmlAttributeName.Name);
        }
示例#5
0
        public void PropertyInfo_ReturnsMetadataOfAdaptingProperty()
        {
            // Arrange
            var property            = GetPropertyInfo(nameof(TestType.Property));
            var runtimePropertyInfo = new RuntimePropertyInfo(property);

            // Act
            var actual = runtimePropertyInfo.Property;

            // Assert
            Assert.Same(property, actual);
            var runtimeTypeInfo = Assert.IsType <RuntimeTypeInfo>(runtimePropertyInfo.PropertyType);

            Assert.Same(property.PropertyType, runtimeTypeInfo.TypeInfo);
        }