public void TestSetValueWriteThrough() { ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<Object, Object>(2, 5.0f, 1); Assert.IsTrue(map.IsEmpty()); for (int i = 0; i < 20; i++) { map.Put(i, i); } Assert.IsFalse(map.IsEmpty()); Entry<Object, Object> entry1 = map.EntrySet().Iterator().Next(); // assert that entry1 is not 16 Assert.IsTrue(!entry1.Key.Equals(16), "entry is 16, test not valid"); // remove 16 (a different key) from map // which just happens to cause entry1 to be cloned in map map.Remove(16); entry1.Value = "XYZ"; Assert.IsTrue(map.ContainsValue("XYZ")); }
/// <summary> /// Does this dictionary contain an element with given key? /// </summary> public bool ContainsValue(TValue value) { return(map.ContainsValue(value)); }
public void TestContainsValue_NullReferenceException() { try { ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5); c.ContainsValue(null); ShouldThrow(); } catch(NullReferenceException) { } }