public void WeakKeyDictionary_RemoveEntry_EntryRemoved() { using (var key = new DisposableTestObject("Remove Me!")) { const int FortyTwo = 42; var dictionary = new WeakKeyDictionary <DisposableTestObject, int>(); Assert.True(dictionary.AddEntry(key, FortyTwo)); Assert.True(dictionary.RemoveEntry(key)); Assert.False(dictionary.ContainsKey(key)); } }
public void WeakKeyDictionary_TryGetRemovedValue_ValueNotRetrieved() { using (var key = new DisposableTestObject("What? Where'd that one go?")) { const int FortyTwo = 42; var dictionary = new WeakKeyDictionary <DisposableTestObject, int>(); Assert.True(dictionary.AddEntry(key, FortyTwo)); Assert.True(dictionary.RemoveEntry(key)); int value; Assert.False(dictionary.TryGetValue(key, out value)); } }