Co2462get_Capacity.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..." );
        ArrayList arrList = null;
        String[] arrCopy = null;
        String [] strHeroes =
            {
                "Aquaman",
                "Atom",
                "Batman",
                "Black Canary",
                "Captain America",
                "Captain Atom",
                "Catwoman",
                "Cyborg",
                "Flash",
                "Green Arrow",
                "Green Lantern",
                "Hawkman",
                "Huntress",
                "Ironman",
                "Nightwing",
                "Robin",
                "SpiderMan",
                "Steel",
                "Superman",
                "Thor",
                "Wildcat",
                "Wonder Woman",
        };
        do
        {
            ++iCountTestcases;
            Console.Error.WriteLine( "[]  Construct ArrayList" );
            try
            {
                arrList = new ArrayList( (ICollection) strHeroes );
                if ( arrList == null )
                {
                    Console.WriteLine( strTest+ "E_101: Failed to construct new ArrayList" );
                    ++iCountErrors;
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine( strTest+ "E_10001: Unexpected Exception: " + ex.ToString() );
                ++iCountErrors;
                break;
            }
            ++iCountTestcases;
            Console.Error.WriteLine( "[]  Obtain list capacity" );
            try
            {
                int nCapacity = arrList.Capacity;
                int nSize = arrList.Count;
                if ( nCapacity < nSize )
                {
                    String strInfo = strTest + " error: ";
                    strInfo = strInfo + "Capacity == <"+ nCapacity + "> ";
                    strInfo = strInfo + "Size <"+ nSize + "> ";
                    Console.WriteLine( strTest+ "E_202: " + strInfo );
                    ++iCountErrors;
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine( strTest+ "E_10002: 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;
        Co2462get_Capacity oCbTest = new Co2462get_Capacity();

        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 Co2462get_Capacity::runTest
Co2462get_Capacity