Co5704get_LastAccessTime.runTest C# (CSharp) Method

runTest() public method

public runTest ( ) : bool
return bool
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        String strLoc = "Loc_000oo";
        String strValue = String.Empty;
        int iCountErrors = 0;
        int iCountTestcases = 0;
        try
        {
            String filName = s_strTFAbbrev+"TestFile";			
            FileInfo fil2;
            Stream stream;
            if(File.Exists(filName))
                File.Delete(filName);
            strLoc = "Loc_r8r7j";
            new FileStream(filName, FileMode.Create).Close();
            fil2 = new FileInfo(filName);
            stream = fil2.OpenWrite();
            stream.Write(new Byte[]{10}, 0, 1);
            stream.Close();
            Thread.Sleep(4000);
            fil2.Refresh();
            iCountTestcases++;
            try 
            {
                DateTime d1 = DateTime.Now ;
                DateTime d2 = fil2.LastAccessTime;
                if(d1.Year != d2.Year || d1.Month != d2.Month || d1.Month != d2.Month) 
                {
                    iCountErrors++;
                    printerr( "Error_20hjx! Creation time cannot be correct");
                }
            } 
            catch (Exception exc) 
            {
                iCountErrors++;
                printerr( "Error_20fhd! Unexpected exceptiont thrown: "+exc.ToString());
                printinfo( "");
            }
            strLoc = "Loc_20yxc";
            stream = fil2.Open(FileMode.Open);
            stream.Read(new Byte[1], 0, 1);
            stream.Close();		
            fil2.Refresh();
            Thread.Sleep(1000);
            iCountTestcases++;
            try 
            {
                DateTime d1 = DateTime.Now ;
                DateTime d2 = fil2.LastAccessTime;
                if(d1.Year != d2.Year || d1.Month != d2.Month || d1.Month != d2.Month) 
                {
                    iCountErrors++;
                    Console.WriteLine((DateTime.Now-fil2.LastAccessTime).TotalMilliseconds);
                    printerr( "Eror_209x9! LastAccessTime is way off");
                }
            } 
            catch (Exception exc) 
            {
                iCountErrors++;
                printerr( "Error_209jx! Unexpected exception thrown: "+exc.ToString());
            } 
            fil2.Delete();
            if(File.Exists(filName))
                File.Delete(filName);
        } 
        catch (Exception exc_general ) 
        {
            ++iCountErrors;
            Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
        }
        if ( iCountErrors == 0 )
        {
            Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
            return true;
        }
        else
        {
            Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
            return false;
        }
    }
    public void printerr ( String err )

Usage Example

Example #1
0
    public static void Main(String[] args)
    {
        bool bResult = false;
        Co5704get_LastAccessTime cbA = new Co5704get_LastAccessTime();

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