public void RemovingAKeyOfOneObjectDoesNotAffectOtherKeysForSameObject() { object o = new object(); WeakRefDictionary <object, object> dict = new WeakRefDictionary <object, object>(); dict.Add("foo1", o); dict.Add("foo2", o); dict.Remove("foo1"); Assert.Same(o, dict["foo2"]); }
public void RemovingAKeyDoesNotAffectOtherKeys() { object o1 = new object(); object o2 = new object(); WeakRefDictionary <object, object> dict = new WeakRefDictionary <object, object>(); dict.Add("foo1", o1); dict.Add("foo2", o2); dict.Remove("foo1"); Assert.Same(o2, dict["foo2"]); }
public void CanRemoveAnObjectThatWasAlreadyAdded() { object o = new object(); WeakRefDictionary <object, object> dict = new WeakRefDictionary <object, object>(); dict.Add("foo", o); dict.Remove("foo"); Assert.Throws <KeyNotFoundException>( delegate { object unused = dict["foo"]; }); }
public override bool Remove(object key) { Guard.ArgumentNotNull(key, "key"); return(references.Remove(key)); }
public void RemovingANonExistantKeyDoesntThrow() { WeakRefDictionary <object, object> dict = new WeakRefDictionary <object, object>(); dict.Remove("foo1"); }