コード例 #1
0
ファイル: co8682ctor.cs プロジェクト: ArildF/masters
 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     ListDictionary ld; 
     try
     {
         Console.WriteLine("--- default ctor ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         ld = new ListDictionary();
         Console.WriteLine("1. compare to null");
         iCountTestcases++;
         if (ld == null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, dictionary is null after default ctor");
         } 
         Console.WriteLine("2. check Count");
         iCountTestcases++;
         if (ld.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002, Count = {0} after default ctor", ld.Count);
         }
         Console.WriteLine("3. check Item(some_key)");
         iCountTestcases++;
         if (ld["key"] != null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003, Item(some_key) returned non-null after default ctor");
         }
         Console.WriteLine("4. check ToString()");
         iCountTestcases++;
         string temp = ld.ToString();
         Console.WriteLine(" ToString(): " + temp);
         if (temp.IndexOf("ListDictionary") == -1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004, ToString() doesn't contain \"ListDictionary\"");
         }
         Console.WriteLine("5. check returned Type");
         iCountTestcases++;
         temp = ld.GetType().ToString().Trim();
         Console.WriteLine(" GetType(): " + temp);
         if (temp.IndexOf("ListDictionary") == -1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0005: returned type doesn't contain \"ListDictionary\"");
         }
         Console.WriteLine("6. compare returned Type of two dictionary");
         iCountTestcases++;
         string temp1 = (new ListDictionary()).GetType().ToString().Trim();
         if (String.Compare(temp, temp1) != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0006: returned types of two collections differ");
         }
         Console.WriteLine("7. check Keys collection");
         iCountTestcases++;
         System.Collections.ICollection keys = ld.Keys;
         if ( keys.Count != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0007: Keys contains {0} keys after default ctor", keys.Count);
         }
         Console.WriteLine("8. check Values collection");
         iCountTestcases++;
         System.Collections.ICollection values = ld.Values;
         if ( values.Count != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0008: Values contains {0} items after default ctor", values.Count);
         }
         Console.WriteLine("9. Add(name, value)");
         iCountTestcases++;
         ld.Add("Name", "Value");
         if (ld.Count != 1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0009a: Count returned {0} instead of 1", ld.Count);
         }
         if (String.Compare(ld["Name"].ToString(), "Value", false) != 0)  
         {  
             iCountErrors++;
             Console.WriteLine("Err_0009b: Item() returned unexpected value");
         }
         Console.WriteLine("10. Clear()");
         iCountTestcases++;
         ld.Clear();
         if (ld.Count != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_00010a: Count returned {0} instead of 0 after Clear()", ld.Count);
         }
         if (ld["Name"] != null)  
         {  
             iCountErrors++;
             Console.WriteLine("Err_00010b: Item() returned non-null value after Clear()");
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
コード例 #2
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int            iCountErrors    = 0;
        int            iCountTestcases = 0;
        String         strLoc          = "Loc_000oo";
        ListDictionary ld;

        try
        {
            Console.WriteLine("--- default ctor ---");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            ld = new ListDictionary();
            Console.WriteLine("1. compare to null");
            iCountTestcases++;
            if (ld == null)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001, dictionary is null after default ctor");
            }
            Console.WriteLine("2. check Count");
            iCountTestcases++;
            if (ld.Count != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002, Count = {0} after default ctor", ld.Count);
            }
            Console.WriteLine("3. check Item(some_key)");
            iCountTestcases++;
            if (ld["key"] != null)
            {
                iCountErrors++;
                Console.WriteLine("Err_0003, Item(some_key) returned non-null after default ctor");
            }
            Console.WriteLine("4. check ToString()");
            iCountTestcases++;
            string temp = ld.ToString();
            Console.WriteLine(" ToString(): " + temp);
            if (temp.IndexOf("ListDictionary") == -1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0004, ToString() doesn't contain \"ListDictionary\"");
            }
            Console.WriteLine("5. check returned Type");
            iCountTestcases++;
            temp = ld.GetType().ToString().Trim();
            Console.WriteLine(" GetType(): " + temp);
            if (temp.IndexOf("ListDictionary") == -1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005: returned type doesn't contain \"ListDictionary\"");
            }
            Console.WriteLine("6. compare returned Type of two dictionary");
            iCountTestcases++;
            string temp1 = (new ListDictionary()).GetType().ToString().Trim();
            if (String.Compare(temp, temp1) != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0006: returned types of two collections differ");
            }
            Console.WriteLine("7. check Keys collection");
            iCountTestcases++;
            System.Collections.ICollection keys = ld.Keys;
            if (keys.Count != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0007: Keys contains {0} keys after default ctor", keys.Count);
            }
            Console.WriteLine("8. check Values collection");
            iCountTestcases++;
            System.Collections.ICollection values = ld.Values;
            if (values.Count != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0008: Values contains {0} items after default ctor", values.Count);
            }
            Console.WriteLine("9. Add(name, value)");
            iCountTestcases++;
            ld.Add("Name", "Value");
            if (ld.Count != 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0009a: Count returned {0} instead of 1", ld.Count);
            }
            if (String.Compare(ld["Name"].ToString(), "Value", false) != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0009b: Item() returned unexpected value");
            }
            Console.WriteLine("10. Clear()");
            iCountTestcases++;
            ld.Clear();
            if (ld.Count != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_00010a: Count returned {0} instead of 0 after Clear()", ld.Count);
            }
            if (ld["Name"] != null)
            {
                iCountErrors++;
                Console.WriteLine("Err_00010b: Item() returned non-null value after Clear()");
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }