Ejemplo n.º 1
0
        public void GetAttributeFromTypeReturnsNullIfAttributeIsNotPresentOnType()
        {
            Type type = typeof(Person);

            TestMember1Attribute attribute = type.GetAttribute <TestMember1Attribute>();

            Assert.IsNull(attribute);
        }
Ejemplo n.º 2
0
        public void GetAttributeFromMemberReturnsAttribute()
        {
            Expression <Func <Person, int> > selector = p => p.Age;
            PropertyInfo property = selector.GetPropertyInfo();

            TestMember1Attribute attribute = property.GetAttribute <TestMember1Attribute>();

            Assert.IsNotNull(attribute);
            Assert.AreEqual(4, attribute.Id);
        }