public Boolean runTest()
{
Console.WriteLine( s_strTFPath +" "+ s_strTFName +" ,for "+ s_strClassMethod +" ,Source ver "+ s_strDtTmVer );
String strLoc = "Loc_000oo";
Hashtable hash = null;
int iCountErrors = 0;
int iCountTestcases = 0;
strLoc = "Loc_001oo";
try
{
++iCountTestcases;
hash = new Hashtable( Int32.MaxValue, .1f, null, null );
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_0001! hashtable should have thrown ArgumentException here" );
}
catch( ArgumentException )
{
}
catch( Exception ex )
{
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_1001! we expected ArgumentException but got exception " + ex.ToString() );
}
try
{
++iCountTestcases;
hash = new Hashtable( 100, .1f, null, null );
}
catch( Exception ex )
{
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_1002! we expected no exception but got exception " + ex.ToString() );
}
Int32 iNumberOfElements = 100;
for(int i=0; i<iNumberOfElements; i++)
{
hash.Add("Key_" + i, "Value_" + i);
}
iCountTestcases++;
if(hash.Count != iNumberOfElements)
{
iCountErrors++;
Console.WriteLine("Err_742dsf! Expected value not returned, " + hash.Count);
}
DictionaryEntry[] strValueArr = new DictionaryEntry[hash.Count];
hash.CopyTo(strValueArr, 0);
Hashtable hsh3 = new Hashtable();
for(int i=0; i<iNumberOfElements; i++)
{
if(!hash.Contains("Key_" + i))
{
iCountErrors++;
Console.WriteLine("Err_742ds8f! Expected value not returned, " + hash.Contains("Key_" + i));
}
if(!hash.ContainsKey("Key_" + i))
{
iCountErrors++;
Console.WriteLine("Err_742389dsaf! Expected value not returned, " + hash.ContainsKey("Key_" + i));
}
if(!hash.ContainsValue("Value_" + i))
{
iCountErrors++;
Console.WriteLine("Err_563fgd! Expected value not returned, " + hash.ContainsValue("Value_" + i));
}
if(!hash.ContainsValue(((DictionaryEntry)strValueArr[i]).Value))
{
iCountErrors++;
Console.WriteLine("Err_87429dsfd! Expected value not returned, " + ((DictionaryEntry)strValueArr[i]).Value);
}
try
{
hsh3.Add(((DictionaryEntry)strValueArr[i]).Value, null);
}
catch(Exception)
{
iCountErrors++;
Console.WriteLine("Err_74298dsd! Exception thrown for " + ((DictionaryEntry)strValueArr[i]).Value);
}
}
try
{
++iCountTestcases;
hash = new Hashtable( 5, .01f, null, null );
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_0003! hashtable should have thrown ArgumentOutOfRangeException here" );
}
catch( ArgumentOutOfRangeException )
{
}
catch( Exception ex )
{
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_1003! we expected ArgumentOutOfRangeException but got exception " + ex.ToString() );
}
try
{
++iCountTestcases;
hash = new Hashtable( 5, 100.1f, null, null );
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_0004! hashtable should have thrown ArgumentOutOfRangeException here" );
}
catch( ArgumentOutOfRangeException )
{
}
catch( Exception ex )
{
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_1004! we expected ArgumentOutOfRangeException but got exception " + ex.ToString() );
}
try
{
++iCountTestcases;
hash = new Hashtable( Int32.MaxValue, 100.1f, null, null );
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_0004! hashtable should have thrown ArgumentOutOfRangeException here" );
}
catch( ArgumentOutOfRangeException )
{
}
catch( Exception ex )
{
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_1004! we expected ArgumentOutOfRangeException but got exception " + ex.ToString() );
}
try
{
++iCountTestcases;
hash = new Hashtable( Int32.MinValue, 10.1f, null, null );
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_0005! hashtable should have thrown ArgumentOutOfRangeException here" );
}
catch( ArgumentOutOfRangeException )
{
}
catch( Exception ex )
{
++iCountErrors;
Console.WriteLine( s_strTFAbbrev +" Error_1005! we expected ArgumentOutOfRangeException but got exception strLoc= " + strLoc + ex.ToString() );
}
if ( iCountErrors == 0 )
{
Console.WriteLine( "paSs. "+ s_strTFPath +" "+ s_strTFName +" ,iCountTestcases="+ iCountTestcases.ToString() );
return true;
}
else
{
Console.WriteLine( "ACTIVE BUGS: " + s_strActiveBugNums );
Console.WriteLine( "FAiL! "+ s_strTFPath +" "+ s_strTFName +" ,iCountErrors="+ iCountErrors.ToString() +" ,BugNums?: "+ s_strActiveBugNums );
return false;
}
}
public static void printUsage()