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