Co8826BoxedObjectCheck.runTest C# (CSharp) Method

runTest() public method

public runTest ( ) : Boolean
return Boolean
 public Boolean runTest()
   {
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc="123_er";
   Console.Out.Write( s_strClassMethod );
   Console.Out.Write( ": " );
   Console.Out.Write( s_strTFPath + s_strTFName );
   Console.Out.Write( ": " );
   Console.Out.Write( s_strDtTmVer );
   Console.Out.WriteLine( " runTest started..." );
   object [] tests = new object[] {
     true, false,
     Byte.MinValue,   Byte.MaxValue, (Byte)0,
     SByte.MinValue,  SByte.MaxValue, (SByte)0,
     Int16.MinValue,  Int16.MaxValue, (Int16)0,
     UInt16.MinValue, UInt16.MaxValue, (UInt16)0,
     Int32.MinValue,  Int32.MaxValue, (Int32)0,
     UInt32.MinValue, UInt32.MaxValue, (UInt32)0,
     Int64.MinValue,  Int64.MaxValue, (Int64)0,
     UInt64.MinValue, UInt64.MaxValue, (UInt64)0,
     Char.MinValue,   Char.MaxValue, (Char)0,
     Double.MinValue, Double.MaxValue, (Double)0,
     Single.MinValue, Single.MaxValue, (Single)0,
     DateTime.MinValue, DateTime.Now, DateTime.MaxValue};
   try {
   iCountTestcases++;	
   strLoc="Loc_642cdf";
   iCountTestcases++;	
   foreach(Object o in tests){								
   if((ValueTypeSafety.GetSafeObject(o)==o)){
   iCountTestcases++;
   Console.WriteLine("Err_9345sgd! Wrong value returned");
   }
   }
   strLoc="Loc_642cdf";
   iCountTestcases++;	
   foreach(Object o in tests){								
   if(!(ValueTypeSafety.GetSafeObject(o).Equals(o))){
   iCountTestcases++;
   Console.WriteLine("Err_93427rsg! Wrong value returned");
   }
   }
   strLoc="Loc_642cdf";
   iCountTestcases++;	
   foreach(Object o in tests){								
   if(!(o.Equals(ValueTypeSafety.GetSafeObject(o)))){
   iCountTestcases++;
   Console.WriteLine("Err_93427rsg! Wrong value returned");
   }
   }
   strLoc="Loc_642cdf";
   iCountTestcases++;	
   foreach(Object o in tests){								
   if(!(Object.Equals(ValueTypeSafety.GetSafeObject(o), o))){
   iCountTestcases++;
   Console.WriteLine("Err_93427rsg! Wrong value returned");
   }
   }
   strLoc="Loc_642cdf";
   iCountTestcases++;	
   foreach(Object o in tests){								
   if((Object.ReferenceEquals(ValueTypeSafety.GetSafeObject(o), o))){
   iCountTestcases++;
   Console.WriteLine("Err_93427rsg! Wrong value returned");
   }
   }
   Object o1 = E.ONE;
   Console.WriteLine(Object.ReferenceEquals(ValueTypeSafety.GetSafeObject(o1), o1));
   Console.WriteLine((ValueTypeSafety.GetSafeObject(o1) == o1));
   Console.WriteLine(o1.GetType().IsPrimitive);
   IConvertible icon = (IConvertible)o1;
   Object o2 = icon.ToType(typeof(object), null);
   Console.WriteLine(Object.ReferenceEquals(ValueTypeSafety.GetSafeObject(o2), o2));
   Console.WriteLine((ValueTypeSafety.GetSafeObject(o2) == o2));
   strLoc="Loc_642cdf";
   iCountTestcases++;	
   Int32 count=0;
   foreach(Type type in typeof(String).Module.GetTypes()){
   if(type.IsValueType && !type.IsEnum){
   try{
   Object oo1 = Activator.CreateInstance(type) as IConvertible;
   if((oo1)!=null){
   Object oo2 = ((IConvertible)oo1).ToType(typeof(object), null);
   count++;
   if(Object.ReferenceEquals(oo2, oo1)){
   iCountTestcases++;
   Console.WriteLine("Err_92475sg! Unexpected value returned, {0}", type);
   }
   }
   }catch{
   }
   }
   }
   Console.WriteLine("Checked {0} Types, ", count);
   }catch (Exception exc_general){
   ++iCountErrors;
   Console.WriteLine( s_strTFAbbrev +"Error Err_8888yyy!  strLoc=="+ strLoc +" ,exc_general=="+ exc_general );
   }
   if ( iCountErrors == 0 ){
   Console.Error.WriteLine( "paSs.   "+ s_strTFPath +" "+ s_strTFName +"  ,iCountTestcases=="+ iCountTestcases );
   return true;
   } else {
   Console.Error.WriteLine( "FAiL!   "+ s_strTFPath +" "+ s_strTFName +"  ,iCountErrors=="+ iCountErrors +""+ s_strActiveBugNums );
   return false;
   }
   }
 public static void Main( String[] args ) 

Usage Example

Example #1
0
    public static void Main(String[] args)
    {
        Boolean bResult = false;
        Co8826BoxedObjectCheck oCbTest = new Co8826BoxedObjectCheck();

        try
        {
            bResult = oCbTest.runTest();
        }
        catch (Exception exc_main)
        {
            bResult = false;
            Console.WriteLine(s_strTFAbbrev + "FAiL!  Error Err_9999zzz!  Uncaught Exception caught in main(), exc_main==" + exc_main);
        }
        if (!bResult)
        {
            Console.WriteLine(s_strTFName + s_strTFPath);
            Console.Error.WriteLine(" ");
            Console.Error.WriteLine("FAiL!  " + s_strTFAbbrev);
            Console.Error.WriteLine(" ");
        }
        if (bResult == true)
        {
            Environment.ExitCode = 0;
        }
        else
        {
            Environment.ExitCode = 1;
        }
    }
All Usage Examples Of Co8826BoxedObjectCheck::runTest
Co8826BoxedObjectCheck