Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Does this dictionary contain an element with given key?
 /// </summary>
 public bool ContainsValue(TValue value)
 {
     return(map.ContainsValue(value));
 }
Exemplo n.º 3
0
 public void TestContainsValue_NullReferenceException()
 {
     try
     {
         ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5);
         c.ContainsValue(null);
         ShouldThrow();
     }
     catch(NullReferenceException)
     {
     }
 }