public void RemoveTest() { using (FileBackedDictionary<int, int> dictionary = new FileBackedDictionary<int, int>()) { dictionary.Add(0, 0); Assert.IsTrue(dictionary.ContainsKey(0)); dictionary.Remove(0); Assert.IsFalse(dictionary.ContainsKey(0)); Assert.AreEqual(dictionary.Count, 0); } }
public void RemoveTest() { using (FileBackedDictionary <int, int> dictionary = new FileBackedDictionary <int, int>()) { dictionary.Add(0, 0); Assert.IsTrue(dictionary.ContainsKey(0)); dictionary.Remove(0); Assert.IsFalse(dictionary.ContainsKey(0)); Assert.AreEqual(dictionary.Count, 0); } }
public void CompactTest() { using (FileBackedDictionary <int, int> dictionary = new FileBackedDictionary <int, int>()) { for (int i = 0; i < 10000; i += 4) { dictionary.Add(i, 4); if (i % 400 == 0) { dictionary[i] = 400; } else if (i % 100 == 0) { dictionary.Remove(i); } } dictionary.Compact(); for (int i = 0; i < 10000; i++) { if (i % 400 == 0) { Assert.AreEqual(dictionary[i], 400); } else if (i % 100 == 0) { Assert.IsFalse(dictionary.ContainsKey(i), i.ToString()); } else if (i % 4 == 0) { Assert.AreEqual(dictionary[i], 4); } else { Assert.IsFalse(dictionary.ContainsKey(i), i.ToString()); } } } }
public void CompactTest() { using (FileBackedDictionary<int, int> dictionary = new FileBackedDictionary<int, int>()) { for (int i = 0; i < 10000; i += 4) { dictionary.Add(i, 4); if (i % 400 == 0) dictionary[i] = 400; else if (i % 100 == 0) dictionary.Remove(i); } dictionary.Compact(); for (int i = 0; i < 10000; i++) { if (i % 400 == 0) Assert.AreEqual(dictionary[i], 400); else if (i % 100 == 0) Assert.IsFalse(dictionary.ContainsKey(i), i.ToString()); else if (i % 4 == 0) Assert.AreEqual(dictionary[i], 4); else Assert.IsFalse(dictionary.ContainsKey(i), i.ToString()); } } }