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

NegTest4() private method

private NegTest4 ( ) : void
return void
        public static void NegTest4()
        {
            MemberInfo element = null;
            Type attributeType = typeof(ObsoleteAttribute);
            Type clsType = typeof(DerivedClass);

            Assert.Throws<ArgumentNullException>(() => (ObsoleteAttribute)Attribute.GetCustomAttribute(element, attributeType, false));
            attributeType = null;
            element = typeof(TestClass).GetMethod("method1");
            Assert.Throws<ArgumentNullException>(() => (ObsoleteAttribute)Attribute.GetCustomAttribute(element, attributeType, false));
            attributeType = typeof(object);
            Assert.Throws<ArgumentException>(() => Attribute.GetCustomAttribute(element, attributeType, false));

            Assert.Throws<AmbiguousMatchException>(() => Attribute.GetCustomAttribute(typeof(Attribute).GetMethod("GetCustomAttribute"), typeof(Attribute), false));

        }