public Boolean runTest()
{
int iCountErrors = 0;
int iCountTestcases = 0;
Console.Error.WriteLine( strName + ": " + strTest + " runTest started..." );
Console.WriteLine( "ACTIVE BUGS " + strActiveBugs );
ArrayList arrList = null;
String [] strHeroes = new String[]
{
"Aquaman",
"Atom",
"Batman",
"Black Canary",
"Captain America",
"Captain Atom",
"Catwoman",
"Cyborg",
"Flash",
"Green Arrow",
"Green Lantern",
"Hawkman",
null,
"Ironman",
"Nightwing",
"Robin",
"SpiderMan",
"Steel",
null,
"Thor",
"Wildcat",
null
};
do
{
++iCountTestcases;
Console.Error.WriteLine( "Normal Contains" );
try
{
arrList = new ArrayList(strHeroes );
for ( int i = 0; i < strHeroes.Length; i++ )
{
if ( ! arrList.Contains( strHeroes[i] ) )
{
++iCountErrors;
Console.WriteLine( "Err_101a, Contains returns false but shour return true at position " + i.ToString() );
}
}
}
catch (Exception ex)
{
Console.WriteLine( "Err_101b, unexpected exception " + ex.ToString() );
++iCountErrors;
break;
}
++iCountTestcases;
Console.Error.WriteLine( "[] Normal Contains which expects false" );
try
{
arrList = new ArrayList(strHeroes );
for ( int i = 0; i < strHeroes.Length; i++ )
{
for ( int j = 0; j < strHeroes.Length; j++ )
{
arrList.Remove( strHeroes[i] );
}
if ( arrList.Contains( strHeroes[i] ) )
{
++iCountErrors;
Console.WriteLine( "Err_102a, Contains returns true but should return false at position " + i.ToString() );
}
}
}
catch (Exception ex)
{
Console.WriteLine( "Err_102b, unexpected exception " + ex.ToString() );
++iCountErrors;
break;
}
++iCountTestcases;
Console.Error.WriteLine( "[] Normal Contains on empty list" );
try
{
arrList = new ArrayList();
for ( int i = 0; i < strHeroes.Length; i++ )
{
if ( arrList.Contains( strHeroes[i] ) )
{
++iCountErrors;
Console.WriteLine( "Err_103a, Contains returns true but should return false at position " + i.ToString() );
}
}
}
catch (Exception ex)
{
Console.WriteLine( "Err_103b, unexpected exception " + ex.ToString() );
++iCountErrors;
break;
}
}
while ( false );
Console.Error.Write( strName );
Console.Error.Write( ": " );
if ( iCountErrors == 0 )
{
Console.Error.WriteLine( strTest + " iCountTestcases==" + iCountTestcases.ToString() + " paSs" );
return true;
}
else
{
Console.WriteLine( strTest + " FAiL");
Console.Error.WriteLine( strTest + " iCountErrors==" + iCountErrors.ToString() );
return false;
}
}
public static void Main( String[] args )