TestIsDefined_Type() public method

public TestIsDefined_Type ( MemberInfo mem ) : bool
mem System.Reflection.MemberInfo
return bool
        public bool RunTest()
        {
            print(strPath + strTest + "  RunTest() started.");
            string        strLoc   = "L_000";
            MyClass       myclass  = new MyClass("myclass");
            MyClass2      myclass2 = new MyClass2("myclass2");
            bool          isattr   = false;
            ParameterInfo param    = null;
            ParameterInfo param2   = null;
            Type          type     = null;
            Type          type2    = null;

            try
            {
                iCountTestcases++;
                strLoc = "L_200_001";
                param  = this.GetType().GetMethod("Dummy").GetParameters() [0];
                if (param == null)
                {
                    iCountErrors++;
                    Util.printerr("E_200_dj13 - param == null");
                }
                iCountTestcases++;
                strLoc = "L_200_001.2";
                isattr = Attribute.IsDefined(param, typeof(System.Attribute), true);
                if (isattr)
                {
                    iCountErrors++;
                    Util.printerr("E_200_oi32 - IsDefined returned true!c");
                }
                iCountTestcases++;
                strLoc = "L_200_001.3";
                try {
                    isattr = Attribute.IsDefined(param, typeof(System.Int32), true);
                    iCountErrors++;
                    Util.printerr("E_200_oi32 - Should 've thrown ArgExc");
                }
                catch (ArgumentException) {
                }
                iCountTestcases++;
                strLoc = "L_200_002";
                type   = myclass.GetType();
                param  = type.GetMethod("MyMethod").GetParameters() [0];
                if (param == null)
                {
                    iCountErrors++;
                    Util.printerr("E_200_75yhg - param == null");
                }
                iCountTestcases++;
                strLoc = "L_200_002.1";
                try {
                    isattr = Attribute.IsDefined(param, null, false);
                    iCountErrors++;
                    Util.printerr("E_200_oi32 - Should 've thrown ArgNullExc");
                }
                catch (ArgumentException) {
                }
                iCountTestcases++;
                strLoc = "L_200_002.1.2";
                try {
                    isattr = Attribute.IsDefined((ParameterInfo)null, typeof(ClassLib_Attributes.CA_AMfalse_INfalse), false);
                    iCountErrors++;
                    Util.printerr("E_200_oi322 - Should 've thrown ArgNullExc");
                }
                catch (ArgumentException) {
                }
                type = myclass.GetType();
                iCountTestcases++;
                strLoc = "L_200_003.4";
                param  = type.GetConstructor(new Type [] { typeof(String) }).GetParameters() [0];
                myclass.TestIsDefined_Type(param);
                iCountTestcases++;
                strLoc = "L_200_003.5";
                param  = type.GetMethod("MyMethod").GetParameters() [0];
                myclass.TestIsDefined_Type(param);
                type2 = myclass2.GetType();
                iCountTestcases++;
                strLoc = "L_2_200_003.4";
                param2 = type2.GetConstructor(new Type [] { typeof(String) }).GetParameters() [0];
                myclass2.TestIsDefined_Type(param2);
                iCountTestcases++;
                strLoc = "L_2_200_003.5";
                param2 = type2.GetMethod("MyMethod").GetParameters() [0];
                myclass2.TestIsDefined_Type(param2);
            }
            catch (Exception exc_runTest) {
                ++myclass2.iCountErrors;
                printerr("Err_888un! - Uncaught Exception caught in runTest(); strLoc == " + strLoc);
                printexc(exc_runTest);
                print(exc_runTest.StackTrace);
            }
            iCountErrors    = myclass.iCountErrors + myclass2.iCountErrors;
            iCountTestcases = myclass.iCountTestcases + myclass2.iCountTestcases;
            if (iCountErrors == 0)
            {
                return(true);
            }
            else
            {
                print("Related Bugs: " + strBug);
                print("FAiL!   " + strPath + strTest + "  iCountErrors==" + iCountErrors.ToString());
                return(false);
            }
        }
 public bool RunTest()
   {
   print (strPath + strTest + "  RunTest() started.");
   string strLoc="L_000";
   MyClass myclass = new MyClass ();
   MyClass2 myclass2 = new MyClass2 ();
   MemberInfo mem = null;
   MemberInfo mem2 = null;
   bool isattr = false;
   Type type = null;
   Type type2 = null;
   try  
     {
     strLoc="L_200_001";
     iCountTestcases++;
     strLoc="L_200_001";
     type = this.GetType ();
     mem = type.GetMethod ("RunTest");
     if (mem == null) {
     iCountErrors++;
     Util.printerr ("E_200_fk23 - mem == null");
     }
     iCountTestcases++;
     strLoc="L_200_001.2";
     try {
     isattr = Attribute.IsDefined (mem, typeof (System.Int32), true); 
     iCountErrors++;
     Util.printerr ("E_200_8dj2 - Should 've thrown ArgNullExc");
     }
     catch (ArgumentException ) {
     }
     iCountTestcases++;
     strLoc="L_200_001.3";
     isattr = Attribute.IsDefined (mem, typeof (System.Attribute), true); 
     if (isattr) {
     iCountErrors++;
     Util.printerr ("E_200_83fk - IsDefined returned true");
     }
     iCountTestcases++;
     strLoc="L_200_002";
     type = myclass.GetType ();
     mem = type.GetMethod ("MyMethod");
     if (mem == null) {
     iCountErrors++;
     Util.printerr ("E_200_75yhg - mem == null");
     }
     iCountTestcases++;
     strLoc="L_200_002.1";
     try {
     isattr = Attribute.IsDefined (mem, null, false);
     iCountErrors++;
     Util.printerr ("E_200_oi32 - Should 've thrown ArgNullExc");
     }
     catch (ArgumentException ) {
     }
     iCountTestcases++;
     strLoc="L_200_002.1.2";
     try {
     isattr = Attribute.IsDefined ((MemberInfo) null, typeof (ClassLib_Attributes.CA_AMfalse_INfalse), false);
     iCountErrors++;
     Util.printerr ("E_200_oi322 - Should 've thrown ArgNullExc");
     }
     catch (ArgumentException ) {
     }
     iCountTestcases++;
     strLoc="L_200_002.5";
     type = myclass.GetType ();
     mem = type;
     myclass.TestIsDefined_Type (mem);
     iCountTestcases++;
     strLoc="L_200_003.4";
     mem = type.GetConstructor (Type.EmptyTypes);
     myclass.TestIsDefined_Type (mem);
     iCountTestcases++;
     strLoc="L_200_003.5";
     mem = type.GetMethod ("MyMethod");
     myclass.TestIsDefined_Type (mem);
     iCountTestcases++;
     strLoc="L_200_004.5";
     mem = type.GetField ("MyField");
     myclass.TestIsDefined_Type (mem);
     iCountTestcases++;
     strLoc="L_200_005.5";
     mem = type.GetProperty ("MyProp");
     myclass.TestIsDefined_Type (mem);
     iCountTestcases++;
     strLoc="L_2_200_002.5";
     type2 = myclass2.GetType ();
     mem2 = type2;
     myclass2.TestIsDefined_Type (mem2);
     iCountTestcases++;
     strLoc="L_2_200_003.4";
     mem2 = type2.GetConstructor (Type.EmptyTypes);
     myclass2.TestIsDefined_Type (mem2);
     iCountTestcases++;
     strLoc="L_2_200_003.5";
     mem2 = type2.GetMethod ("MyMethod");
     myclass2.TestIsDefined_Type (mem2);
     iCountTestcases++;
     strLoc="L_2_200_004.5";
     mem2 = type2.GetField ("MyField");
     myclass2.TestIsDefined_Type (mem2);
     iCountTestcases++;
     strLoc="L_2_200_005.5";
     mem2 = type2.GetProperty ("MyProp");
     myclass2.TestIsDefined_Type (mem2);
     }
   catch( Exception exc_runTest ) {
   ++myclass2.iCountErrors;
   printerr ("Err_888un! - Uncaught Exception caught in runTest(); strLoc == " + strLoc);
   printexc (exc_runTest);
   print (exc_runTest.StackTrace);
   }
   iCountErrors = myclass.iCountErrors + myclass2.iCountErrors;
   iCountTestcases = myclass.iCountTestcases + myclass2.iCountTestcases;
   if ( iCountErrors == 0 ) {   return true; }
   else {
   print  ("Related Bugs: " + strBug);
   print ("FAiL!   " + strPath +strTest + "  iCountErrors==" +  iCountErrors.ToString ());
   return false;
   }
   }
        public bool RunTest()
        {
            print(strPath + strTest + "  RunTest() started.");
            string     strLoc   = "L_000";
            MyClass    myclass  = new MyClass();
            MyClass2   myclass2 = new MyClass2();
            MemberInfo mem      = null;
            MemberInfo mem2     = null;
            bool       isattr   = false;
            Type       type     = null;
            Type       type2    = null;

            try
            {
                strLoc = "L_200_001";
                iCountTestcases++;
                strLoc = "L_200_001";
                type   = this.GetType();
                mem    = type.GetMethod("RunTest");
                if (mem == null)
                {
                    iCountErrors++;
                    Util.printerr("E_200_fk23 - mem == null");
                }
                iCountTestcases++;
                strLoc = "L_200_001.2";
                try {
                    isattr = Attribute.IsDefined(mem, typeof(System.Int32), true);
                    iCountErrors++;
                    Util.printerr("E_200_8dj2 - Should 've thrown ArgNullExc");
                }
                catch (ArgumentException) {
                }
                iCountTestcases++;
                strLoc = "L_200_001.3";
                isattr = Attribute.IsDefined(mem, typeof(System.Attribute), true);
                if (isattr)
                {
                    iCountErrors++;
                    Util.printerr("E_200_83fk - IsDefined returned true");
                }
                iCountTestcases++;
                strLoc = "L_200_002";
                type   = myclass.GetType();
                mem    = type.GetMethod("MyMethod");
                if (mem == null)
                {
                    iCountErrors++;
                    Util.printerr("E_200_75yhg - mem == null");
                }
                iCountTestcases++;
                strLoc = "L_200_002.1";
                try {
                    isattr = Attribute.IsDefined(mem, null, false);
                    iCountErrors++;
                    Util.printerr("E_200_oi32 - Should 've thrown ArgNullExc");
                }
                catch (ArgumentException) {
                }
                iCountTestcases++;
                strLoc = "L_200_002.1.2";
                try {
                    isattr = Attribute.IsDefined((MemberInfo)null, typeof(ClassLib_Attributes.CA_AMfalse_INfalse), false);
                    iCountErrors++;
                    Util.printerr("E_200_oi322 - Should 've thrown ArgNullExc");
                }
                catch (ArgumentException) {
                }
                iCountTestcases++;
                strLoc = "L_200_002.5";
                type   = myclass.GetType();
                mem    = type;
                myclass.TestIsDefined_Type(mem);
                iCountTestcases++;
                strLoc = "L_200_003.4";
                mem    = type.GetConstructor(Type.EmptyTypes);
                myclass.TestIsDefined_Type(mem);
                iCountTestcases++;
                strLoc = "L_200_003.5";
                mem    = type.GetMethod("MyMethod");
                myclass.TestIsDefined_Type(mem);
                iCountTestcases++;
                strLoc = "L_200_004.5";
                mem    = type.GetField("MyField");
                myclass.TestIsDefined_Type(mem);
                iCountTestcases++;
                strLoc = "L_200_005.5";
                mem    = type.GetProperty("MyProp");
                myclass.TestIsDefined_Type(mem);
                iCountTestcases++;
                strLoc = "L_2_200_002.5";
                type2  = myclass2.GetType();
                mem2   = type2;
                myclass2.TestIsDefined_Type(mem2);
                iCountTestcases++;
                strLoc = "L_2_200_003.4";
                mem2   = type2.GetConstructor(Type.EmptyTypes);
                myclass2.TestIsDefined_Type(mem2);
                iCountTestcases++;
                strLoc = "L_2_200_003.5";
                mem2   = type2.GetMethod("MyMethod");
                myclass2.TestIsDefined_Type(mem2);
                iCountTestcases++;
                strLoc = "L_2_200_004.5";
                mem2   = type2.GetField("MyField");
                myclass2.TestIsDefined_Type(mem2);
                iCountTestcases++;
                strLoc = "L_2_200_005.5";
                mem2   = type2.GetProperty("MyProp");
                myclass2.TestIsDefined_Type(mem2);
            }
            catch (Exception exc_runTest) {
                ++myclass2.iCountErrors;
                printerr("Err_888un! - Uncaught Exception caught in runTest(); strLoc == " + strLoc);
                printexc(exc_runTest);
                print(exc_runTest.StackTrace);
            }
            iCountErrors    = myclass.iCountErrors + myclass2.iCountErrors;
            iCountTestcases = myclass.iCountTestcases + myclass2.iCountTestcases;
            if (iCountErrors == 0)
            {
                return(true);
            }
            else
            {
                print("Related Bugs: " + strBug);
                print("FAiL!   " + strPath + strTest + "  iCountErrors==" + iCountErrors.ToString());
                return(false);
            }
        }
 public bool RunTest()
   {
   print (strPath + strTest + "  RunTest() started.");
   string strLoc="L_000";
   MyClass myclass = new MyClass ("myclass");
   MyClass2 myclass2 = new MyClass2 ("myclass2");
   bool isattr = false;
   ParameterInfo param = null;
   ParameterInfo param2 = null;
   Type type = null;
   Type type2 = null;
   try  
     {
     iCountTestcases++;
     strLoc="L_200_001";
     param = this.GetType ().GetMethod ("Dummy").GetParameters () [0];
     if (param == null) {
     iCountErrors++;
     Util.printerr ("E_200_dj13 - param == null");
     }
     iCountTestcases++;
     strLoc="L_200_001.2";
     isattr = Attribute.IsDefined (param, typeof (System.Attribute), true);
     if (isattr) {
     iCountErrors++;
     Util.printerr ("E_200_oi32 - IsDefined returned true!c");
     }
     iCountTestcases++;
     strLoc="L_200_001.3";
     try {
     isattr = Attribute.IsDefined (param, typeof (System.Int32), true);
     iCountErrors++;
     Util.printerr ("E_200_oi32 - Should 've thrown ArgExc");
     }
     catch (ArgumentException ) {
     }
     iCountTestcases++;
     strLoc="L_200_002";
     type = myclass.GetType ();
     param = type.GetMethod ("MyMethod").GetParameters () [0];
     if (param == null) {
     iCountErrors++;
     Util.printerr ("E_200_75yhg - param == null");
     }
     iCountTestcases++;
     strLoc="L_200_002.1";
     try {
     isattr = Attribute.IsDefined (param, null, false);
     iCountErrors++;
     Util.printerr ("E_200_oi32 - Should 've thrown ArgNullExc");
     }
     catch (ArgumentException ) {
     }
     iCountTestcases++;
     strLoc="L_200_002.1.2";
     try {
     isattr = Attribute.IsDefined ((ParameterInfo) null, typeof (ClassLib_Attributes.CA_AMfalse_INfalse), false);
     iCountErrors++;
     Util.printerr ("E_200_oi322 - Should 've thrown ArgNullExc");
     }
     catch (ArgumentException ) {
     }
     type = myclass.GetType ();
     iCountTestcases++;
     strLoc="L_200_003.4";
     param = type.GetConstructor (new Type [] {typeof (String)}).GetParameters () [0];
     myclass.TestIsDefined_Type (param);
     iCountTestcases++;
     strLoc="L_200_003.5";
     param = type.GetMethod ("MyMethod").GetParameters () [0];
     myclass.TestIsDefined_Type (param);
     type2 = myclass2.GetType ();
     iCountTestcases++;
     strLoc="L_2_200_003.4";
     param2 = type2.GetConstructor (new Type [] {typeof (String)}).GetParameters () [0];
     myclass2.TestIsDefined_Type (param2);
     iCountTestcases++;
     strLoc="L_2_200_003.5";
     param2 = type2.GetMethod ("MyMethod").GetParameters () [0];
     myclass2.TestIsDefined_Type (param2);
     }
   catch( Exception exc_runTest ) {
   ++myclass2.iCountErrors;
   printerr ("Err_888un! - Uncaught Exception caught in runTest(); strLoc == " + strLoc);
   printexc (exc_runTest);
   print (exc_runTest.StackTrace);
   }
   iCountErrors = myclass.iCountErrors + myclass2.iCountErrors;
   iCountTestcases = myclass.iCountTestcases + myclass2.iCountTestcases;
   if ( iCountErrors == 0 ) {   return true; }
   else {
   print  ("Related Bugs: " + strBug);
   print ("FAiL!   " + strPath +strTest + "  iCountErrors==" +  iCountErrors.ToString ());
   return false;
   }
   }