public void Type_ReturnsNewInstance() { var attributeMetadata1 = AttributeUtility.GetCustomAttributesWithMetadata(typeof(SampleClass), typeof(InheritedAttribute), false).Single(); var attributeMetadata2 = AttributeUtility.GetCustomAttributesWithMetadata(typeof(SampleClass), typeof(InheritedAttribute), false).Single(); Assert.That(attributeMetadata1.AttributeInstance, Is.Not.SameAs(attributeMetadata2.AttributeInstance)); }
public void DerivedClass_WithTypeFilter() { AttributeWithMetadata[] attributes = AttributeUtility.GetCustomAttributesWithMetadata(typeof(DerivedClassWithAttribute), typeof(BaseInheritedAttribute), true).ToArray(); Assert.That(attributes, Is.EquivalentTo(new object[] { new AttributeWithMetadata(typeof(BaseClassWithAttribute), new BaseInheritedAttribute("BaseClass")), new AttributeWithMetadata(typeof(BaseClassWithAttribute), new DerivedInheritedAttribute("BaseClass")), new AttributeWithMetadata(typeof(DerivedClassWithAttribute), new BaseInheritedAttribute("DerivedClass")), new AttributeWithMetadata(typeof(DerivedClassWithAttribute), new DerivedInheritedAttribute("DerivedClass")), })); }
public void BaseClass_InheritedTrue() { AttributeWithMetadata[] attributes = AttributeUtility.GetCustomAttributesWithMetadata(typeof(BaseClassWithAttribute), typeof(Attribute), true).ToArray(); Assert.That(attributes, Is.EquivalentTo(new object[] { new AttributeWithMetadata(typeof(BaseClassWithAttribute), new BaseInheritedAttribute("BaseClass")), new AttributeWithMetadata(typeof(BaseClassWithAttribute), new DerivedInheritedAttribute("BaseClass")), new AttributeWithMetadata(typeof(BaseClassWithAttribute), new BaseNonInheritedAttribute("BaseClass")), new AttributeWithMetadata(typeof(BaseClassWithAttribute), new DerivedNonInheritedAttribute("BaseClass")), new AttributeWithMetadata(typeof(BaseClassWithAttribute), new InheritedNotMultipleAttribute("BaseClass")), })); }
public void DerivedClass_InheritedFalse() { AttributeWithMetadata[] attributes = AttributeUtility.GetCustomAttributesWithMetadata(typeof(DerivedClassWithAttribute), typeof(Attribute), false).ToArray(); Assert.That(attributes, Is.EquivalentTo(new object[] { new AttributeWithMetadata(typeof(DerivedClassWithAttribute), new BaseInheritedAttribute("DerivedClass")), new AttributeWithMetadata(typeof(DerivedClassWithAttribute), new DerivedInheritedAttribute("DerivedClass")), new AttributeWithMetadata(typeof(DerivedClassWithAttribute), new BaseNonInheritedAttribute("DerivedClass")), new AttributeWithMetadata(typeof(DerivedClassWithAttribute), new DerivedNonInheritedAttribute("DerivedClass")), new AttributeWithMetadata(typeof(DerivedClassWithAttribute), new SuppressAttributesAttribute(typeof(InheritedNotMultipleAttribute))), new AttributeWithMetadata(typeof(DerivedClassWithAttribute), new InheritedNotMultipleAttribute("DerivedClass")), })); }
public void ObjectClass_InheritedTrue() { AttributeWithMetadata[] attributes = AttributeUtility.GetCustomAttributesWithMetadata(typeof(object), typeof(Attribute), true).ToArray(); Assert.That(attributes.Length, Is.EqualTo(typeof(object).GetCustomAttributes(false).Length)); }