Esempio n. 1
0
        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));
        }
Esempio n. 2
0
 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")),
     }));
 }
Esempio n. 3
0
 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")),
     }));
 }
Esempio n. 4
0
 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")),
     }));
 }
Esempio n. 5
0
 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));
 }