Пример #1
0
        public void Data_XmlElementAttribute_Defined()
        {
            // Arrange & Act & Assert
            var propertyInfo = TypeAssert.PropertyHasAttribute <Resx>("Data", typeof(XmlElementAttribute));

            AttributeAssert.ValidateProperty(propertyInfo, typeof(XmlElementAttribute), nameof(XmlElementAttribute.ElementName), "data");
        }
        public void DescriptionFor_Attribute_Defined(Type attributeType, string attributePropertyName, object attributePropertyValue)
        {
            // Arrange & Act & Assert
            var propertyInfo = TypeAssert.PropertyHasAttribute <DescriptionTagHelper>("DescriptionFor", attributeType);

            AttributeAssert.ValidateProperty(propertyInfo, attributeType, attributePropertyName, attributePropertyValue);
        }
        public void Value_XmlElementAttribute_Defined()
        {
            // Arrange & Act & Assert
            var propertyInfo = TypeAssert.PropertyHasAttribute <Resx.DataNode>("Value", typeof(XmlElementAttribute));

            AttributeAssert.ValidateProperty(propertyInfo, typeof(XmlElementAttribute), nameof(XmlElementAttribute.ElementName), "value");
        }
        public void Name_XmlAttributeAttribute_Defined()
        {
            // Arrange & Act & Assert
            var propertyInfo = TypeAssert.PropertyHasAttribute <Resx.DataNode>("Name", typeof(XmlAttributeAttribute));

            AttributeAssert.ValidateProperty(propertyInfo, typeof(XmlAttributeAttribute), nameof(XmlAttributeAttribute.AttributeName), "name");
        }
        public void Attribute_Defined(Type attributeType, string firstAttributePropertyName, object firstAttributePropertyValue, string secondAttributePropertyName, object secondAttributePropertyValue)
        {
            // Arrange & Act & Assert
            var typeInfo = TypeAssert.HasAttribute <DescriptionTagHelper>(attributeType);

            AttributeAssert.ValidateProperty(typeInfo, attributeType, firstAttributePropertyName, firstAttributePropertyValue);
            AttributeAssert.ValidateProperty(typeInfo, attributeType, secondAttributePropertyName, secondAttributePropertyValue);
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAttributes()
        public virtual void testAttributes()
        {
            ICollection <AttributeAssumption> attributesAssumptions = AttributesAssumptions;

            if (attributesAssumptions == null)
            {
                assertThatType().hasNoAttributes();
            }
            else
            {
                assertThat(attributesAssumptions).hasSameSizeAs(modelElementType.Attributes);
                foreach (AttributeAssumption assumption in attributesAssumptions)
                {
                    assertThatType().hasAttributes(assumption.attributeName);
                    AttributeAssert attributeAssert = assertThatAttribute(assumption.attributeName);

                    attributeAssert.hasOwningElementType(modelElementType);

                    if (!string.ReferenceEquals(assumption.@namespace, null))
                    {
                        attributeAssert.hasNamespaceUri(assumption.@namespace);
                    }
                    else
                    {
                        attributeAssert.hasNoNamespaceUri();
                    }

                    if (assumption.isIdAttribute)
                    {
                        attributeAssert.IdAttribute;
                    }
                    else
                    {
                        attributeAssert.NotIdAttribute;
                    }

                    if (assumption.isRequired)
                    {
                        attributeAssert.Required;
                    }
                    else
                    {
                        attributeAssert.Optional;
                    }

                    if (assumption.defaultValue == null)
                    {
                        attributeAssert.hasNoDefaultValue();
                    }
                    else
                    {
                        attributeAssert.hasDefaultValue(assumption.defaultValue);
                    }
                }
            }
        }
Пример #7
0
        public void Id_Attribute_Defined(Type attributeType, string attributePropertyName, object attributePropertyValue)
        {
            // Arrange & Act & Assert
            var propertyInfo = TypeAssert.PropertyHasAttribute <Entity <int> >("Id", attributeType);

            if (attributePropertyName != null)
            {
                AttributeAssert.ValidateProperty(propertyInfo, attributeType, attributePropertyName, attributePropertyValue);
            }
        }
Пример #8
0
 public void ValidateProperty_ProtectedProperty_Success()
 {
     // Arrange & Act & Assert
     AttributeAssert.ValidateProperty(
         typeof(FakeClassModel).GetProperty(nameof(FakeClassModel.Value)),
         typeof(FakePropertyAttribute),
         "ProtectedValue",
         "TestProtectedValue"
         );
 }
Пример #9
0
 public void ValidateProperty_ThrowsNotNullExceptionIfNoAttribute()
 {
     // Arrange & Act & Assert
     Assert.Throws <NotNullException>(
         () => AttributeAssert.ValidateProperty(
             typeof(FakeClassModel).GetProperty(nameof(FakeClassModel.Value)),
             typeof(FakeClassAttribute),
             "NoSuchProperty",
             "TestValue"
             )
         );
 }
Пример #10
0
 public void ValidateProperty_ThrowsEqualExceptionIfAttributePropertyValueNotEqual()
 {
     // Arrange & Act & Assert
     Assert.Throws <EqualException>(
         () => AttributeAssert.ValidateProperty(
             typeof(FakeClassModel).GetProperty(nameof(FakeClassModel.Value)),
             typeof(FakePropertyAttribute),
             "Value",
             "OtherValue"
             )
         );
 }