System.Tests.GetCustomAttribute.NegTest8 C# (CSharp) Method

NegTest8() private method

private NegTest8 ( ) : void
return void
        public static void NegTest8()
        {
            ParameterInfo element = null;
            Type attributeType = typeof(ArgumentUsageAttribute);
            Type clsType = typeof(DerivedClass);
            MethodInfo minfo = clsType.GetMethod("TestMethod");
            ParameterInfo[] paramInfos = minfo.GetParameters();

            Assert.Throws<ArgumentNullException>(() => (ArgumentUsageAttribute)Attribute.GetCustomAttribute(element, attributeType, false));
            attributeType = null;
            Assert.Throws<ArgumentNullException>(() => (ArgumentUsageAttribute)Attribute.GetCustomAttribute(paramInfos[0], attributeType, false));
            attributeType = typeof(object);
            Assert.Throws<ArgumentException>(() => (ArgumentUsageAttribute)Attribute.GetCustomAttribute(paramInfos[0], attributeType, false));

        }
    }