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

            Assert.IsNotNull(enumerator);
        }
예제 #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");
         }
     });
 }
예제 #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);
         }
     });
 }
예제 #4
0
        public void TryAdd_CanHandleMultipleThreads()
        {
            var dictionary = new ThreadSafeDictionary <string, string>();

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