public void Test_Weak_ForEach() { BigObject[] keys1 = new BigObject[20]; BigObject[] keys2 = new BigObject[20]; for (int i = 0; i < keys1.Length; i++) { keys1[i] = new BigObject(i); dictionary.Add(keys1[i], "value"); } for (int i = 0; i < keys2.Length; i++) { keys2[i] = new BigObject(i); dictionary.Add(keys2[i], "value"); } Assert.AreEqual(40, dictionary.Count); keys2 = null; int count = 0; foreach (var de in dictionary) { CallGC(); count++; } Assert.LessOrEqual(20, count); Assert.Greater(40, count); Assert.IsNotNull(keys1); }
public void Test_Weak_1() { BigObject key = new BigObject(1); BigObject key2 = new BigObject(2); dictionary.Add(key, "value"); Assert.AreEqual("value", dictionary[key]); key = null; CallGC(); dictionary.Add(key2, "value2"); Assert.AreEqual(1, dictionary.Count); }
public void Test_Weak_2() { BigObject key = new BigObject(1); BigObject key2 = new BigObject(2); BigObject key3 = new BigObject(3); dictionary.Add(key, "value"); dictionary.Add(key2, "value2"); Assert.AreEqual("value", dictionary[key]); key = null; CallGC(); dictionary.Add(key3, "value3"); Assert.AreEqual(2, dictionary.Count); Assert.IsNotNull(key2); }
public void Test_Weak_ForEach() { BigObject[] keys1 = new BigObject[20]; BigObject[] keys2 = new BigObject[20]; for (int i = 0; i < keys1.Length; i++) { keys1[i] = new BigObject(i); dictionary.Add(keys1[i], "value"); } for (int i = 0; i < keys2.Length; i++) { keys2[i] = new BigObject(i); dictionary.Add(keys2[i], "value"); } Assert.AreEqual(40, dictionary.Count); keys2 = null; int count = 0; foreach (var de in dictionary) { CallGC(); count++; } Assert.LessOrEqual(20, count); Assert.Greater(40, count); Assert.IsNotNull(keys1); }
public void Test_Weak_2() { BigObject key = new BigObject(1); BigObject key2 = new BigObject(2); BigObject key3 = new BigObject(3); dictionary.Add(key, "value"); dictionary.Add(key2, "value2"); Assert.AreEqual("value", dictionary[key]); key = null; CallGC(); dictionary.Add(key3, "value3"); Assert.AreEqual(2, dictionary.Count); Assert.IsNotNull(key2); }
public void Test_Weak_1() { BigObject key = new BigObject(1); BigObject key2 = new BigObject(2); dictionary.Add(key, "value"); Assert.AreEqual("value", dictionary[key]); key = null; CallGC(); dictionary.Add(key2, "value2"); Assert.AreEqual(1, dictionary.Count); }