public void NamedFieldAndFieldValuesDifferentLengths_ThrowsArgumentException(string[] fieldNames, object[] fieldValues, string paramName) { ConstructorInfo constructor = typeof(CustomAttributeBuilderTest).GetConstructor(new Type[0]); FieldInfo[] namedFields = Helpers.GetFields(fieldNames); Assert.Throws <ArgumentException>(paramName, () => new CustomAttributeBuilder(constructor, new object[0], namedFields, fieldValues)); }
public void Ctor(Type[] ctorParams, object[] constructorArgs, string[] namedFieldNames, object[] fieldValues, object[] expected) { Type attribute = typeof(CustomAttributeBuilderTest); ConstructorInfo constructor = attribute.GetConstructor(ctorParams); FieldInfo[] namedField = Helpers.GetFields(namedFieldNames); CustomAttributeBuilder cab = new CustomAttributeBuilder(constructor, constructorArgs, namedField, fieldValues); FieldInfo[] verifyFields = Helpers.GetFields(IntField, StringField, GetStringField, GetIntField); VerifyCustomAttribute(cab, attribute, verifyFields, expected); }
public void NullObjectInNamedFields_ThrowsArgumentNullException() { ConstructorInfo constructor = typeof(CustomAttributeBuilderTest).GetConstructor(new Type[0]); Assert.Throws <ArgumentNullException>("namedFields[0]", () => new CustomAttributeBuilder(constructor, new object[0], Helpers.GetFields(null, IntField), new object[] { "TestString", 10 })); }
public void NullObjectInFieldValues_ThrowsArgumentNullException() { ConstructorInfo constructor = typeof(CustomAttributeBuilderTest).GetConstructor(new Type[0]); Assert.Throws <ArgumentNullException>("fieldValues[0]", () => new CustomAttributeBuilder(constructor, new object[0], new PropertyInfo[0], new object[0], Helpers.GetFields(IntField, StringField), new object[] { null, 10 })); }