Esempio n. 1
0
        public void GetEnumerator_CastToIEnumerble_ReturnsEnumerator()
        {
            var dictionary = new ThreadSafeDictionary <string, string>();
            var enumerator = ((IEnumerable)dictionary).GetEnumerator();

            Assert.IsNotNull(enumerator);
        }
Esempio n. 2
0
 private static Action Add(ThreadSafeDictionary <string, string> dictionary)
 {
     return(() =>
     {
         Thread.Sleep(50);
         for (int i = 0; i < 50; i++)
         {
             dictionary.TryAdd("Key", "Value");
         }
     });
 }
Esempio n. 3
0
 private static Action Remove(ThreadSafeDictionary <string, string> dictionary)
 {
     return(() =>
     {
         Thread.Sleep(50);
         for (int i = 0; i < 50; i++)
         {
             string value;
             dictionary.TryRemove("Key", out value);
         }
     });
 }
Esempio n. 4
0
        public void TryAdd_CanHandleMultipleThreads()
        {
            var dictionary = new ThreadSafeDictionary <string, string>();

            ParallelInvoker.Invoke(50, Add(dictionary), Remove(dictionary));
        }