Co2934get_Seconds.runTest C# (CSharp) Method

runTest() public method

public runTest ( ) : bool
return bool
 public virtual bool runTest()
   {
   int iCountErrors = 0;
   int iCountTestcases = 0;
   Console.Error.WriteLine( strName + ": " + strTest + " runTest started..." );
   TimeSpan	ts;
   int iDays = -1;
   int iHours = -1;
   int iMinutes = -1;
   int iSeconds = -1;
   do
     {
     ++iCountTestcases;
     Console.Error.WriteLine( "[]  Construct positive TimeSpan object" );
     try
       {
       iDays = 4;
       iHours = 12;
       iMinutes = 23;
       iSeconds = 34;
       ts = new TimeSpan( iDays, iHours, iMinutes, iSeconds );
       if ( iSeconds != ts.Seconds )
	 {
	 String strInfo = strTest + " error: ";
	 strInfo = strInfo + "Expected Seconds <" + iSeconds + "> ";
	 strInfo = strInfo + "Returned Seconds <" + ts.Seconds + "> ";
	 Console.WriteLine( strTest+ "E_101c: " + strInfo );
	 ++iCountErrors;
	 break;
	 }
       }
     catch (Exception ex)
       {
       Console.WriteLine( strTest+ "E_10001: Unexpected Exception: " + ex.ToString() );
       ++iCountErrors;
       break;
       }
     ++iCountTestcases;
     Console.Error.WriteLine( "[]  Construct TimeSpan object using negative hours, month and seconds" );
     try
       {
       iDays = -4;
       iHours = -12;
       iMinutes = -23;
       iSeconds = -34;
       ts = new TimeSpan( iDays, iHours, iMinutes, iSeconds );
       if ( iSeconds != ts.Seconds )
	 {
	 String strInfo = strTest + " error: ";
	 strInfo = strInfo + "Expected Seconds <" + iSeconds + "> ";
	 strInfo = strInfo + "Returned Seconds <" + ts.Seconds + "> ";
	 Console.WriteLine( strTest+ "E_101c: " + strInfo );
	 ++iCountErrors;
	 break;
	 }
       }
     catch (Exception ex)
       {
       Console.WriteLine( strTest+ "E_20202: Unexpected Exception: " + ex.ToString() );
       ++iCountErrors;
       break;
       }
     ++iCountTestcases;
     Console.Error.WriteLine( "[]  Construct TimeSpan object using zero hours, month and seconds" );
     try
       {
       iDays = 0;
       iHours = 0;
       iMinutes = 0;
       iSeconds = 0;
       ts = new TimeSpan( iHours, iMinutes, iSeconds );
       if ( iSeconds != ts.Seconds )
	 {
	 String strInfo = strTest + " error: ";
	 strInfo = strInfo + "Expected Seconds <" + iSeconds + "> ";
	 strInfo = strInfo + "Returned Seconds <" + ts.Seconds + "> ";
	 Console.WriteLine( strTest+ "E_101c: " + strInfo );
	 ++iCountErrors;
	 break;
	 }
       }
     catch (Exception ex)
       {
       Console.WriteLine( strTest+ "E_30303: Unexpected Exception: " + ex.ToString() );
       ++iCountErrors;
       break;
       }
     }
   while ( false );
   Console.Error.Write( strName );
   Console.Error.Write( ": " );
   if ( iCountErrors == 0 )
     {
     Console.Error.WriteLine( strTest + " iCountTestcases==" + iCountTestcases + " paSs" );
     return true;
     }
   else
     {
     System.String strFailMsg = null;
     Console.WriteLine( strTest+ strPath );
     Console.WriteLine( strTest+ "FAiL" );
     Console.Error.WriteLine( strTest + " iCountErrors==" + iCountErrors );
     return false;
     }
   }
 public static void Main( String[] args )

Usage Example

Ejemplo n.º 1
0
    public static void Main(String[] args)
    {
        bool bResult = false;
        Co2934get_Seconds oCbTest = new Co2934get_Seconds();

        try
        {
            bResult = oCbTest.runTest();
        }
        catch (Exception ex)
        {
            bResult = false;
            Console.WriteLine(strTest + strPath);
            Console.WriteLine(strTest + "E_1000000");
            Console.WriteLine(strTest + "FAiL: Uncaught exception detected in Main()");
            Console.WriteLine(strTest + ex.ToString());
        }
        if (bResult == true)
        {
            Environment.ExitCode = 0;
        }
        else
        {
            Environment.ExitCode = 1;
        }
    }
All Usage Examples Of Co2934get_Seconds::runTest
Co2934get_Seconds