ClassLib_Test.Co4763GetCustomAttributes_MemInfo.RunTest C# (CSharp) Method

RunTest() public method

public RunTest ( ) : bool
return bool
 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;
   Attribute[] attrs = null;
   Attribute[] attrs2 = null;
   Type type = null;
   Type type2 = null;
   try  
     {
     strLoc="L_100_001";
     iCountTestcases++;
     strLoc="L_100_001.4";
     try {
     attrs = Attribute.GetCustomAttributes ((MemberInfo) null, true);
     iCountErrors++;
     Util.printerr ("E_100_duo21 - Should 've thrown ArgNullExc");
     }
     catch (ArgumentException ) {
     }
     iCountTestcases++;
     strLoc="L_100_001.4.2";
     type = myclass.GetType();
     mem = type.GetMethod ("TestGetCustomAttributes");
     if (mem == null) {
     iCountErrors++;
     Util.printerr ("E_100_jkjs - mem == null");
     }
     iCountTestcases++;
     strLoc="L_100_001.5";
     attrs = Attribute.GetCustomAttributes (mem, true);
     if (attrs == null) {
     iCountErrors++;
     Util.printerr ("E_100_iudo - attrs == null");
     return false;
     }
     iCountTestcases++;
     strLoc="L_100_001.6";
     if (attrs.Length != 0+1) {
     iCountErrors++;
     Util.printerr ("E_100_f3fw - attrs.Length != 1");
     Util.print (attrs.Length);
     }
     iCountTestcases++;
     strLoc="L_2_100_001.4.2";
     type2 = myclass2.GetType();
     mem2 = type2.GetMethod ("TestGetCustomAttributes");
     if (mem2 == null) {
     iCountErrors++;
     Util.printerr ("E_2_100_jkjs - mem2 == null");
     }
     iCountTestcases++;
     strLoc="L_2_100_001.5";
     attrs2 = Attribute.GetCustomAttributes (mem2, true);
     if (attrs2 == null) {
     iCountErrors++;
     Util.printerr ("E_2_100_iudo - attrs2 == null");
     return false;
     }
     iCountTestcases++;
     strLoc="L_2_100_001.6";
     if (attrs2.Length != 0+1) {
     iCountErrors++;
     Util.printerr ("E_2_100_f3fw - attrs2.Length != 1");
     Util.print (attrs2.Length);
     }
     iCountTestcases++;
     strLoc="L_100_001.7";
     type = myclass.GetType();
     mem = type;
     if (mem == null) {
     iCountErrors++;
     Util.printerr ("E_100_skj2 - mem == null");
     }
     else {
     myclass.TestGetCustomAttributes (mem);
     iCountTestcases++;
     strLoc="L_100_001.7.2";
     myclass.TestGetCustomAttributes2 (mem);
     }
     iCountTestcases++;
     strLoc="L_100_001.8";
     mem = type.GetConstructor (Type.EmptyTypes);
     if (mem == null) {
     iCountErrors++;
     Util.printerr ("E_100_001.8_skj2 - mem == null");
     }
     else {
     myclass.TestGetCustomAttributes (mem);
     iCountTestcases++;
     strLoc="L_100_001.8.2";
     myclass.TestGetCustomAttributes2 (mem);
     }
     iCountTestcases++;
     strLoc="L_100_002";
     mem = type.GetMethod ("MyMethod");
     if (mem == null) {
     iCountErrors++;
     Util.printerr ("E_100_002_skj2 - mem == null");
     }
     else {
     myclass.TestGetCustomAttributes (mem);
     iCountTestcases++;
     strLoc="L_100_002.7.2";
     myclass.TestGetCustomAttributes2 (mem);
     }
     iCountTestcases++;
     strLoc="L_100_003";
     mem = type.GetField ("MyField");
     if (mem == null) {
     iCountErrors++;
     Util.printerr ("E_100_003_skj2 - mem == null");
     }
     else {
     myclass.TestGetCustomAttributes (mem);
     iCountTestcases++;
     strLoc="L_100_003.7.2";
     myclass.TestGetCustomAttributes2 (mem);
     }
     iCountTestcases++;
     strLoc="L_100_004";
     mem = type.GetProperty ("MyProp");
     if (mem == null) {
     iCountErrors++;
     Util.printerr ("E_100_004_skj2 - mem == null");
     }
     else {
     myclass.TestGetCustomAttributes (mem);
     iCountTestcases++;
     strLoc="L_100_004.7.2";
     myclass.TestGetCustomAttributes2 (mem);
     }
     iCountTestcases++;
     strLoc="L_100_005";
     mem = type.GetEvent ("MyEvent");
     if (mem == null) {
     iCountErrors++;
     Util.printerr ("E_100_005_skj2 - mem == null");
     }
     else {
     myclass.TestGetCustomAttributes (mem);
     iCountTestcases++;
     strLoc="L_100_005.7.2";
     myclass.TestGetCustomAttributes2 (mem);
     }
     iCountTestcases++;
     strLoc="L_2_100_001.7";
     type2 = myclass2.GetType();
     mem2 = type2;
     if (mem2 == null) {
     iCountErrors++;
     Util.printerr ("E_2_100_skj2 - mem2 == null");
     }
     else {
     myclass2.TestGetCustomAttributes (mem2);
     iCountTestcases++;
     strLoc="L_2_100_001.7.2";
     myclass2.TestGetCustomAttributes2 (mem2);
     }
     iCountTestcases++;
     strLoc="L_2_100_001.8";
     mem2 = type2.GetConstructor (Type.EmptyTypes);
     if (mem2 == null) {
     iCountErrors++;
     Util.printerr ("E_2_100_001.8_skj2 - mem2 == null");
     }
     else {
     myclass2.TestGetCustomAttributes (mem2);
     iCountTestcases++;
     strLoc="L_2_100_001.8.2";
     myclass2.TestGetCustomAttributes2 (mem2);
     }
     iCountTestcases++;
     strLoc="L_2_100_002";
     mem2 = type2.GetMethod ("MyMethod");
     if (mem2 == null) {
     iCountErrors++;
     Util.printerr ("E_2_100_002_skj2 - mem2 == null");
     }
     else {
     myclass2.TestGetCustomAttributes (mem2);
     iCountTestcases++;
     strLoc="L_2_100_002.7.2";
     myclass2.TestGetCustomAttributes2 (mem2);
     }
     iCountTestcases++;
     strLoc="L_2_100_003";
     mem2 = type2.GetField ("MyField",BindingFlags.Public|BindingFlags.Instance|BindingFlags.DeclaredOnly);
     if (mem2 == null) {
     iCountErrors++;
     Util.printerr ("E_2_100_003_skj2 - mem2 == null");
     }
     else {
     myclass2.TestGetCustomAttributes (mem2);
     iCountTestcases++;
     strLoc="L_2_100_003.7.2";
     myclass2.TestGetCustomAttributes2 (mem2);
     }
     iCountTestcases++;
     strLoc="L_2_100_004";
     mem2 = type2.GetProperty ("MyProp");
     if (mem2 == null) {
     iCountErrors++;
     Util.printerr ("E_2_100_004_skj2 - mem2 == null");
     }
     else {
     myclass2.TestGetCustomAttributes (mem2);
     iCountTestcases++;
     strLoc="L_2_100_004.7.2";
     myclass2.TestGetCustomAttributes2 (mem2);
     }
     iCountTestcases++;
     strLoc="L_2_100_005";
     mem2 = type2.GetEvent ("MyEvent");
     if (mem2 == null) {
     iCountErrors++;
     Util.printerr ("E_2_100_005_skj2 - mem2 == null");
     }
     else {
     myclass2.TestGetCustomAttributes (mem2);
     iCountTestcases++;
     strLoc="L_2_100_005.7.2";
     myclass2.TestGetCustomAttributes2 (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;
   }
   }
 private static void print(Object str)

Usage Example

示例#1
0
        public static void Main(string[] args)
        {
            bool          bResult = false;
            StringBuilder sblMsg  = new StringBuilder(99);
            Co4763GetCustomAttributes_MemInfo coA = new Co4763GetCustomAttributes_MemInfo();

            try {
                bResult = coA.RunTest();
            }
            catch (Exception exc_main) {
                bResult = false;
                printerr("Err_999zzz! - Uncaught Exception caught in main(): ");
                printexc(exc_main);
                print(exc_main.StackTrace);
            }
            if (!bResult)
            {
                print("PATHTOSOURCE:  " + strPath + strTest + "  FAiL!");
            }
            Environment.ExitCode = ((bResult) ? 0 : 11);
        }
All Usage Examples Of ClassLib_Test.Co4763GetCustomAttributes_MemInfo::RunTest
Co4763GetCustomAttributes_MemInfo