Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }