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

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

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