in clicache/integration-test/DistOpsStepsN.cs [2000:2146]
public virtual void Idictionary_Array_GetEnumerator_Step<TKey, TValue>(IRegion<TKey, TValue> region, TypesClass type, int KeyId, int ValueId)
{
// Generic enumerator
IEnumerator RegionGenericEnumerator = region.GetEnumerator();
// Non-Generic enumerator
IEnumerator<KeyValuePair<TKey, TValue>> RegionEnumerator = region.GetEnumerator();
// Chk before doing generic Enumerator's MoveNext what is the value at Current and that exception is thrown.
try
{
Object r = RegionGenericEnumerator.Current;
Assert.Fail("Should have got InvalidOperationException");
}
catch (InvalidOperationException ex)
{
Util.Log("Got expected InvalidOperationException {0} ", ex);
}
// Chk before doing non-generic Enumerator's MoveNext what is the value at Current and that exception is thrown.
try
{
Object r = RegionEnumerator.Current;
Assert.Fail("Should have got InvalidOperationException");
}
catch (InvalidOperationException ex)
{
Util.Log("Got expected InvalidOperationException {0} ", ex);
}
Util.Log("Idictionary_Array_GetEnumerator_Step 1 complete.");
// Chk after doing Generic Enumerator's Reset, what is the value at Current and that exception is thrown.
RegionGenericEnumerator.Reset();
try
{
Object r = RegionGenericEnumerator.Current;
Assert.Fail("Should have got InvalidOperationException");
}
catch (InvalidOperationException ex)
{
Util.Log("Got expected InvalidOperationException {0} ", ex);
}
// Chk after doing non-Generic Enumerator's Reset, what is the value at Current and that exception is thrown.
RegionEnumerator.Reset();
try
{
Object r = RegionEnumerator.Current;
Assert.Fail("Should have got InvalidOperationException");
}
catch (InvalidOperationException ex)
{
Util.Log("Got expected InvalidOperationException {0} ", ex);
}
Util.Log("Idictionary_Array_GetEnumerator_Step 2 complete.");
//Chk for equality of individual elements from within the dictionary with those with Generic enumerator's current.
RegionGenericEnumerator.MoveNext();
RegionGenericEnumerator.MoveNext();
RegionGenericEnumerator.MoveNext();
RegionGenericEnumerator.MoveNext();
RegionGenericEnumerator.MoveNext();
//Chk for equality of individual elements from within the dictionary with those with non Generic enumerator's current.
RegionEnumerator.MoveNext();
RegionEnumerator.MoveNext();
RegionEnumerator.MoveNext();
RegionEnumerator.MoveNext();
RegionEnumerator.MoveNext();
Util.Log("Idictionary_Array_GetEnumerator_Step 3 complete.");
//Modify region by adding 1 more element and see that accessing Generic enumerator does not throw exception.
region.Add(type.GetTypeItem<TKey>(KeyId, 5), type.GetArrayTypeItem<TValue>(ValueId, 5));
try
{
RegionGenericEnumerator.MoveNext();
Util.Log("No exception expected.");
}
catch (InvalidOperationException ex)
{
Assert.Fail("Got unexpected InvalidOperationException. {0} ", ex);
}
//Modify region by adding 1 more element and see that accessing non Generic enumerator does not throw exception.
region.Add(type.GetTypeItem<TKey>(KeyId, 6), type.GetArrayTypeItem<TValue>(ValueId, 6));
try
{
RegionEnumerator.MoveNext();
Util.Log("No exception expected.");
}
catch (InvalidOperationException ex)
{
Assert.Fail("Got unexpected InvalidOperationException. {0} ", ex);
}
Util.Log("Idictionary_Array_GetEnumerator_Step 4 complete.");
// Since region has 5 entries chk while enumerating, count of generic enumerator's iterator.
RegionGenericEnumerator.Reset();
int RegionEntryCount = 0;
while (RegionGenericEnumerator.MoveNext())
{
RegionEntryCount++;
}
Assert.IsTrue(5 == RegionEntryCount, "Region entry count does not match.");
RegionEntryCount = 0; //This is done for iteration where localRegionInstance calls this method.
// Since region has 5 entries chk while enumerating, count of non-generic enumerator's iterator.
RegionEnumerator.Reset();
while (RegionEnumerator.MoveNext())
{
RegionEntryCount++;
}
Assert.IsTrue(5 == RegionEntryCount, "Region entry count does not match.");
RegionEntryCount = 0;
Util.Log("Idictionary_Array_GetEnumerator_Step 5 complete.");
// Chk after doing Generic Enumerator's MoveNext to end what is the value at Current and that exception is thrown.
RegionGenericEnumerator.MoveNext();
try
{
Object r = RegionGenericEnumerator.Current;
Assert.Fail("Should have got InvalidOperationException");
}
catch (InvalidOperationException ex)
{
Util.Log("Got expected InvalidOperationException {0} ", ex);
}
// Chk after doing non-Generic Enumerator's MoveNext to end what is the value at Current and that exception is thrown
RegionEnumerator.MoveNext();
try
{
Object r = RegionEnumerator.Current;
Assert.Fail("Should have got InvalidOperationException");
}
catch (InvalidOperationException ex)
{
Util.Log("Got expected InvalidOperationException {0} ", ex);
}
Util.Log("Idictionary_Array_GetEnumerator_Step 6 complete.");
Assert.IsTrue(region.Remove(type.GetTypeItem<TKey>(KeyId, 5)), "Remove should be successfull as entry is present in the region.");
Assert.IsTrue(region.Remove(type.GetTypeItem<TKey>(KeyId, 6)), "Remove should be successfull as entry is present in the region.");
}