in clicache/integration-test/DistOpsStepsN.cs [800:1033]
public virtual void RemoveStepSix()
{
IRegion<object, object> reg0 = CacheHelper.GetVerifyRegion<object, object>(m_regionNames[0]);
IRegion<object, object> reg1 = CacheHelper.GetVerifyRegion<object, object>(m_regionNames[1]);
ICollection<KeyValuePair<Object, Object>> IcollectionRegion0 = reg0;
ICollection<KeyValuePair<Object, Object>> IcollectionRegion1 = reg1;
reg0[m_keys[1]] = m_nvals[1];
reg1[m_keys[3]] = m_nvals[3];
// Try removing value that is present on client as well as server, result should be true.
Assert.IsTrue(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_nvals[1])), "Result of Remove should be true, as this value is present locally, & also present on server.");
Assert.IsTrue(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_nvals[3])), "Result of Remove should be true, as this value is present locally, & also present on server.");
Assert.IsFalse(reg0.ContainsKey(m_keys[1]), "ContainsKey should be false");
Assert.IsFalse(reg0.GetLocalView().ContainsKey(m_keys[1]), "GetLocalView().ContainsKey should be false");
Assert.IsFalse(reg1.ContainsKey(m_keys[3]), "ContainsKey should be false");
Assert.IsFalse(reg1.GetLocalView().ContainsKey(m_keys[3]), "GetLocalView().ContainsKey should be false");
Util.Log("Step 6.1 complete.");
// Try removing value that is present on client but not on server, result should be false.
reg0[m_keys[1]] = m_vals[1];
reg1[m_keys[3]] = m_vals[3];
reg0.GetLocalView()[m_keys[1]] = m_nvals[1];
reg1.GetLocalView()[m_keys[3]] = m_nvals[3];
Assert.IsFalse(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_nvals[1])), "Result of Remove should be false, as this value is present locally, but not present on server.");
Assert.IsFalse(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_nvals[3])), "Result of Remove should be false, as this value is present locally, but not present on server.");
Assert.IsTrue(reg0.ContainsKey(m_keys[1]), "ContainsKey should be true");
Assert.IsTrue(reg0.GetLocalView().ContainsKey(m_keys[1]), "GetLocalView().ContainsKey should be true");
Assert.IsTrue(reg1.ContainsKey(m_keys[3]), "ContainsKey should be true");
Assert.IsTrue(reg1.GetLocalView().ContainsKey(m_keys[3]), "GetLocalView().ContainsKey should be true");
Util.Log("Step 6.2 complete.");
// Try removing value that is not present on client but present on server, result should be false.
reg0.Remove(m_keys[1]);
reg1.Remove(m_keys[3]);
reg0[m_keys[1]] = m_vals[1];
reg1[m_keys[3]] = m_vals[3];
reg0.GetLocalView()[m_keys[1]] = m_nvals[1];
reg1.GetLocalView()[m_keys[3]] = m_nvals[3];
Assert.IsFalse(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_vals[1])), "Result of Remove should be false, as this value is not present locally, but present only on server.");
Assert.IsFalse(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_vals[3])), "Result of Remove should be false, as this value is not present locally, but present only on server.");
Assert.IsTrue(reg0.ContainsKey(m_keys[1]), "ContainsKey should be true");
Assert.IsTrue(reg0.GetLocalView().ContainsKey(m_keys[1]), "GetLocalView().ContainsKey should be true");
Assert.IsTrue(reg1.ContainsKey(m_keys[3]), "ContainsKey should be true");
Assert.IsTrue(reg1.GetLocalView().ContainsKey(m_keys[3]), "GetLocalView().ContainsKey should be true");
Util.Log("Step 6.3 complete.");
// Try removing value that is invalidated on client but exists on server, result should be false.
reg0.Remove(m_keys[1]);
reg1.Remove(m_keys[3]);
reg0[m_keys[1]] = m_vals[1];
reg1[m_keys[3]] = m_vals[3];
reg0.GetLocalView().Invalidate(m_keys[1]);
reg1.GetLocalView().Invalidate(m_keys[3]);
Assert.IsFalse(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_nvals[1])), "Result of Remove should be false, as this value is not present locally, but present only on server.");
Assert.IsFalse(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_nvals[3])), "Result of Remove should be false, as this value is not present locally, but present only on server.");
Assert.IsTrue(reg0.ContainsKey(m_keys[1]), "ContainsKey should be true");
Assert.IsTrue(reg0.GetLocalView().ContainsKey(m_keys[1]), "GetLocalView().ContainsKey should be true");
Assert.IsTrue(reg1.ContainsKey(m_keys[3]), "ContainsKey should be true");
Assert.IsTrue(reg1.GetLocalView().ContainsKey(m_keys[3]), "GetLocalView().ContainsKey should be true");
Util.Log("Step 6.4 complete.");
// Try removing null value, that is invalidated on client but exists on the server, result should be false.
reg0.Remove(m_keys[1]);
reg1.Remove(m_keys[3]);
reg0[m_keys[1]] = m_vals[1];
reg1[m_keys[3]] = m_vals[3];
reg0.GetLocalView().Invalidate(m_keys[1]);
reg1.GetLocalView().Invalidate(m_keys[3]);
Assert.IsFalse(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], null)), "Result of Remove should be false, as this value is not present locally, but present only on server.");
Assert.IsFalse(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], null)), "Result of Remove should be false, as this value is not present locally, but present only on server.");
Assert.IsTrue(reg0.ContainsKey(m_keys[1]), "ContainsKey should be true");
Assert.IsTrue(reg0.GetLocalView().ContainsKey(m_keys[1]), "GetLocalView().ContainsKey should be true");
Assert.IsTrue(reg1.ContainsKey(m_keys[3]), "ContainsKey should be true");
Assert.IsTrue(reg1.GetLocalView().ContainsKey(m_keys[3]), "GetLocalView().ContainsKey should be true");
Util.Log("Step 6.5 complete.");
// Try removing a entry (value) which is not present on client as well as server, result should be false.
Assert.IsFalse(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>("NewKey1", "NewValue1")), "Result of Remove should be false, as this value is not present locally, and not present on server.");
Assert.IsFalse(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>("NewKey3", "NewValue3")), "Result of Remove should be false, as this value is not present locally, and not present on server.");
Assert.IsFalse(reg0.ContainsKey("NewKey1"), "ContainsKey should be false");
Assert.IsFalse(reg0.GetLocalView().ContainsKey("NewKey1"), "GetLocalView().ContainsKey should be false");
Assert.IsFalse(reg1.ContainsKey("NewKey3"), "ContainsKey should be false");
Assert.IsFalse(reg1.GetLocalView().ContainsKey("NewKey3"), "GetLocalView().ContainsKey should be false");
Util.Log("Step 6.6 complete.");
// Try removing a entry with a null value, which is not present on client as well as server, result should be false.
Assert.IsFalse(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>("NewKey1", null)), "Result of Remove should be false, as this value is not present locally, and not present on server.");
Assert.IsFalse(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>("NewKey3", null)), "Result of Remove should be false, as this value is not present locally, and not present on server.");
Assert.IsFalse(reg0.ContainsKey("NewKey1"), "ContainsKey should be false");
Assert.IsFalse(reg0.GetLocalView().ContainsKey("NewKey1"), "GetLocalView().ContainsKey should be false");
Assert.IsFalse(reg1.ContainsKey("NewKey3"), "ContainsKey should be false");
Assert.IsFalse(reg1.GetLocalView().ContainsKey("NewKey3"), "GetLocalView().ContainsKey should be false");
Util.Log("Step 6.7 complete.");
// Try removing a entry (value) which is not present on client but exists on the server, result should be true.
reg0.Remove(m_keys[1]);
reg1.Remove(m_keys[3]);
reg0[m_keys[1]] = m_nvals[1];
reg1[m_keys[3]] = m_nvals[3];
reg0.GetLocalView().Remove(m_keys[1]);
reg1.GetLocalView().Remove(m_keys[3]);
Assert.IsTrue(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_nvals[1])), "Result of Remove should be true, as this value does not exist locally, but exists on server.");
Assert.IsTrue(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_nvals[3])), "Result of Remove should be true, as this value does not exist locally, but exists on server.");
Assert.IsFalse(reg0.ContainsKey(m_keys[1]), "ContainsKey should be false");
Assert.IsFalse(reg0.GetLocalView().ContainsKey(m_keys[1]), "GetLocalView().ContainsKey should be false");
Assert.IsFalse(reg1.ContainsKey(m_keys[3]), "ContainsKey should be false");
Assert.IsFalse(reg1.GetLocalView().ContainsKey(m_keys[3]), "GetLocalView().ContainsKey should be false");
Util.Log("Step6.8 complete.");
reg0[m_keys[1]] = m_nvals[1];
reg1[m_keys[3]] = m_nvals[3];
reg0.Remove(m_keys[1]);
reg1.Remove(m_keys[3]);
Assert.IsFalse(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], null)), "Result of Remove should be false, as this value does not exist locally, but exists on server.");
Assert.IsFalse(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], null)), "Result of Remove should be false, as this value does not exist locally, but exists on server.");
Assert.IsFalse(reg0.ContainsKey(m_keys[1]), "ContainsKey should be false");
Assert.IsFalse(reg0.GetLocalView().ContainsKey(m_keys[1]), "GetLocalView().ContainsKey should be false");
Assert.IsFalse(reg1.ContainsKey(m_keys[3]), "ContainsKey should be false");
Assert.IsFalse(reg1.GetLocalView().ContainsKey(m_keys[3]), "GetLocalView().ContainsKey should be false");
Util.Log("Step6.8.1 complete.");
// Try locally removing an entry which is locally destroyed with a NULL.
reg0[m_keys[1]] = m_vals[1];
reg1[m_keys[3]] = m_vals[3];
Assert.IsTrue(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_vals[1])), "Result of Remove should be true, as this value does not exists locally.");
Assert.IsFalse(IcollectionRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_vals[1])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsTrue(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_vals[3])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(IcollectionRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_vals[3])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(reg0.ContainsKey(m_keys[1]), "ContainsKey should be false");
Assert.IsFalse(reg1.ContainsKey(m_keys[3]), "ContainsKey should be false");
Util.Log("Step6.8.2 complete.");
//-------------------------------------GetLocalView().Remove Testcases------------------------------------------------
ICollection<KeyValuePair<Object, Object>> IcollectionLocalRegion0 = reg0.GetLocalView();
ICollection<KeyValuePair<Object, Object>> IcollectionLocalRegion1 = reg1.GetLocalView();
// Try locally removing an entry (value) which is present on the client.
reg0.Remove(m_keys[1]);
reg1.Remove(m_keys[3]);
reg0.GetLocalView()[m_keys[1]] = m_vals[1];
reg1.GetLocalView()[m_keys[3]] = m_vals[3];
Assert.IsTrue(IcollectionLocalRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_vals[1])), "Result of Remove should be true, as this value exists locally.");
Assert.IsTrue(IcollectionLocalRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_vals[3])), "Result of Remove should be true, as this value exists locally.");
Assert.IsFalse(reg0.GetLocalView().ContainsKey(m_keys[1]), "ContainsKey should be false");
Assert.IsFalse(reg1.GetLocalView().ContainsKey(m_keys[3]), "ContainsKey should be false");
Util.Log("Step6.9 complete.");
Assert.IsFalse(reg0.GetLocalView().Remove(m_keys[1], null), "local Destroy on already removed key should have returned false");
Assert.IsFalse(reg1.GetLocalView().Remove(m_keys[3], null), "local Destroy on already removed key should have returned false");
Util.Log("Step6.10 complete.");
// Try locally removing an entry (value) which is not present on the client (value mismatch).
reg0.GetLocalView()[m_keys[1]] = m_vals[1];
reg1.GetLocalView()[m_keys[3]] = m_vals[3];
Assert.IsFalse(IcollectionLocalRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_nvals[1])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(IcollectionLocalRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_nvals[3])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsTrue(reg0.GetLocalView().ContainsKey(m_keys[1]), "ContainsKey should be true");
Assert.IsTrue(reg1.GetLocalView().ContainsKey(m_keys[3]), "ContainsKey should be true");
Util.Log("Step6.11 complete.");
// Try locally removing an entry (value) which is invalidated with a value.
reg0.GetLocalView().Remove(m_keys[1]);
reg1.GetLocalView().Remove(m_keys[3]);
reg0.GetLocalView()[m_keys[1]] = m_vals[1];
reg1.GetLocalView()[m_keys[3]] = m_vals[3];
reg0.GetLocalView().Invalidate(m_keys[1]);
reg1.GetLocalView().Invalidate(m_keys[3]);
Assert.IsFalse(IcollectionLocalRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_vals[1])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(IcollectionLocalRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_vals[3])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsTrue(reg0.GetLocalView().ContainsKey(m_keys[1]), "ContainsKey should be true");
Assert.IsTrue(reg1.GetLocalView().ContainsKey(m_keys[3]), "ContainsKey should be true");
Util.Log("Step6.12 complete.");
// Try locally removing an entry (value) which is invalidated with a NULL.
reg0.GetLocalView().Remove(m_keys[1]);
reg1.GetLocalView().Remove(m_keys[3]);
reg0.GetLocalView()[m_keys[1]] = m_vals[1];
reg1.GetLocalView()[m_keys[3]] = m_vals[3];
reg0.GetLocalView().Invalidate(m_keys[1]);
reg1.GetLocalView().Invalidate(m_keys[3]);
Assert.IsTrue(IcollectionLocalRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], null)), "Result of Remove should be true, as this value does not exists locally.");
Assert.IsTrue(IcollectionLocalRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], null)), "Result of Remove should be true, as this value does not exists locally.");
Assert.IsFalse(reg0.GetLocalView().ContainsKey(m_keys[1]), "ContainsKey should be false");
Assert.IsFalse(reg1.GetLocalView().ContainsKey(m_keys[3]), "ContainsKey should be false");
Util.Log("Step6.13 complete.");
// Try locally removing an entry (value) with a NULL.
reg0.GetLocalView()[m_keys[1]] = m_vals[1];
reg1.GetLocalView()[m_keys[3]] = m_vals[3];
Assert.IsFalse(IcollectionLocalRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], null)), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(IcollectionLocalRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], null)), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsTrue(reg0.GetLocalView().ContainsKey(m_keys[1]), "ContainsKey should be true");
Assert.IsTrue(reg1.GetLocalView().ContainsKey(m_keys[3]), "ContainsKey should be true");
Util.Log("Step6.14 complete.");
// Try locally removing an entry which is locally destroyed with a value.
reg0.GetLocalView()[m_keys[1]] = m_vals[1];
reg1.GetLocalView()[m_keys[3]] = m_vals[3];
reg0.GetLocalView().Remove(m_keys[1]);
reg1.GetLocalView().Remove(m_keys[3]);
Assert.IsFalse(IcollectionLocalRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_vals[1])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(IcollectionLocalRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_vals[3])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(reg0.GetLocalView().ContainsKey(m_keys[1]), "ContainsKey should be true");
Assert.IsFalse(reg1.GetLocalView().ContainsKey(m_keys[3]), "ContainsKey should be true");
Util.Log("Step6.15 complete.");
// Try locally removing an entry which is locally destroyed with a NULL.
reg0.GetLocalView()[m_keys[1]] = m_vals[1];
reg1.GetLocalView()[m_keys[3]] = m_vals[3];
reg0.GetLocalView().Remove(m_keys[1]);
reg1.GetLocalView().Remove(m_keys[3]);
Assert.IsFalse(IcollectionLocalRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], null)), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(IcollectionLocalRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], null)), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(reg0.GetLocalView().ContainsKey(m_keys[1]), "ContainsKey should be false");
Assert.IsFalse(reg1.GetLocalView().ContainsKey(m_keys[3]), "ContainsKey should be false");
Util.Log("Step6.16 complete.");
// Try locally removing an entry which is already removed.
reg0.GetLocalView()[m_keys[1]] = m_vals[1];
reg1.GetLocalView()[m_keys[3]] = m_vals[3];
Assert.IsTrue(IcollectionLocalRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_vals[1])), "Result of Remove should be true, as this value does not exists locally.");
Assert.IsFalse(IcollectionLocalRegion0.Remove(new KeyValuePair<Object, Object>(m_keys[1], m_vals[1])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsTrue(IcollectionLocalRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_vals[3])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(IcollectionLocalRegion1.Remove(new KeyValuePair<Object, Object>(m_keys[3], m_vals[3])), "Result of Remove should be false, as this value does not exists locally.");
Assert.IsFalse(reg0.GetLocalView().ContainsKey(m_keys[1]), "ContainsKey should be false");
Assert.IsFalse(reg1.GetLocalView().ContainsKey(m_keys[3]), "ContainsKey should be false");
Util.Log("Step6.17 complete.");
// Try locally removing an entry when region scope is not null.
Util.Log("StepSix complete.");
}