public void NamedPropertyAndPropertyValuesDifferentLengths_ThrowsArgumentException(string[] propertyNames, object[] propertyValues, string paramName)
        {
            ConstructorInfo constructor = typeof(CustomAttributeBuilderTest).GetConstructor(new Type[0]);

            PropertyInfo[] namedProperties = Helpers.GetProperties(propertyNames);

            Assert.Throws <ArgumentException>(paramName, () => new CustomAttributeBuilder(constructor, new object[0], namedProperties, propertyValues, new FieldInfo[0], new object[0]));
        }
        public void Ctor(Type[] ctorParams, object[] constructorArgs, string[] namedPropertyNames, object[] propertyValues, string[] namedFieldNames, object[] fieldValues, object[] expected)
        {
            Type            attribute   = typeof(CustomAttributeBuilderTest);
            ConstructorInfo constructor = attribute.GetConstructor(ctorParams);

            FieldInfo[]    namedFields     = Helpers.GetFields(namedFieldNames);
            PropertyInfo[] namedProperties = Helpers.GetProperties(namedPropertyNames);

            CustomAttributeBuilder cab = new CustomAttributeBuilder(constructor, constructorArgs, namedProperties, propertyValues, namedFields, fieldValues);

            FieldInfo[] fields = Helpers.GetFields(IntField, StringField, GetStringField, GetIntField);
            VerifyCustomAttribute(cab, attribute, fields, expected);
        }
        public void NullObjectInNamedProperties_ThrowsArgumentNullException()
        {
            ConstructorInfo constructor = typeof(CustomAttributeBuilderTest).GetConstructor(new Type[0]);

            Assert.Throws <ArgumentNullException>("namedProperties[0]", () => new CustomAttributeBuilder(constructor, new object[0], Helpers.GetProperties(null, IntProperty), new object[] { "TestString", 10 }, new FieldInfo[0], new object[0]));
        }
Esempio n. 4
0
        public void NullObjectInPropertyValues_ThrowsArgumentNullException()
        {
            ConstructorInfo constructor = typeof(CustomAttributeBuilderTest).GetConstructor(new Type[0]);

            Assert.Throws <ArgumentNullException>("propertyValues[0]", () => new CustomAttributeBuilder(constructor, new object[0], Helpers.GetProperties(IntProperty, StringProperty), new object[] { null, 10 }));
        }