public void TestClearBasic()
{
StringBuilder sblMsg = new StringBuilder(99);
SortedList sl2 = null;
StringBuilder sbl3 = new StringBuilder(99);
StringBuilder sbl4 = new StringBuilder(99);
StringBuilder sblWork1 = new StringBuilder(99);
String s1 = null;
String s2 = null;
int i = 0;
//
// Constructor: Create SortedList using this as IComparer and default settings.
//
sl2 = new SortedList(this);
// Verify that the SortedList is not null.
Assert.NotNull(sl2);
// Verify that the SortedList is empty.
Assert.Equal(0, sl2.Count);
// now Clear the list and verify the Count
sl2.Clear(); //removes 0 element
Assert.Equal(0, sl2.Count);
// Testcase: add few key-val pairs
for (i = 0; i < 100; i++)
{
sblMsg.Length = 0;
sblMsg.Append("key_");
sblMsg.Append(i);
s1 = sblMsg.ToString();
sblMsg.Length = 0;
sblMsg.Append("val_");
sblMsg.Append(i);
s2 = sblMsg.ToString();
sl2.Add(s1, s2);
}
// now get the list Count and verify
Assert.Equal(100, sl2.Count);
// now Clear the list and verify the Count
sl2.Clear(); //removes all the 100 elements
Assert.Equal(0, sl2.Count);
}