public void When_deleting_a_key_thrown_KeyNotFoundException_when_accessing_it_afterwards() { TestClass t = new TestClass(10); _dict.Add(345, t); bool removed = _dict.Remove(345); Assert.IsTrue(removed); Assert.AreEqual(0, _dict.Count); t = _dict[345]; }
public void When_removing_key_value_pairs_verify_dictionary_status() { Customer c1 = new Customer { Name = "a" }; Customer c2 = new Customer { Name = "b" }; _dict2.Add(c1, c1); _dict2.Add(c2, c2); KeyValuePair <Customer, Customer> kvp1 = new KeyValuePair <Customer, Customer>(c1, c1); KeyValuePair <Customer, Customer> kvp2 = new KeyValuePair <Customer, Customer>(c2, c2); Assert.IsTrue(_dict2.Remove(kvp1)); Assert.IsFalse(_dict2.Remove(kvp1)); Assert.IsTrue(_dict2.Remove(kvp2)); Assert.IsFalse(_dict2.Remove(kvp2)); }
public void When_removing_objects_verify_count() { Customer c1 = new Customer { Name = "a" }; Customer c2 = new Customer { Name = "b" }; _dict.Add(c1, 1); _dict.Add(c2, 2); _dict.Remove(c1); _dict.Remove(c2); Assert.AreEqual(0, _dict.Count); bool remove = _dict.Remove(c1); Assert.IsFalse(remove); remove = _dict.Remove(c2); Assert.IsFalse(remove); }