Ejemplo n.º 1
0
        public void SafeInvokeAllProgressCallback(float currentProgress)
        {
            var enumerator = m_ProgressCallbackList.GetEnumerator();

            while (enumerator.MoveNext())
            {
                SafeInvokeProgressAction(enumerator.Current.Value, currentProgress);
            }
        }
        public void TrimExcess_Generic_DoesInvalidateEnumeration()
        {
            var dictionary = new LinkedDictionary <TKey, TValue>(20);
            var enumerator = dictionary.GetEnumerator();

            dictionary.TrimExcess(7); // Verify TrimExcess does invalidate enumeration

            Assert.Throws <InvalidOperationException>(() => enumerator.MoveNext());
        }
Ejemplo n.º 3
0
        public void SafeInvokeAllCallback(Object target)
        {
            SafeInvokeAllProgressCallback(1f);

            var enumerator = m_LoadedCallbackList.GetEnumerator();

            while (enumerator.MoveNext())
            {
                SafeInvokeAction(enumerator.Current.Value, target);
            }
        }
        public void TryAdd_ItemAlreadyExists_DoesNotInvalidateEnumerator()
        {
            var dictionary = new LinkedDictionary <string, string>();

            dictionary.Add("a", "b");

            IEnumerator valuesEnum = dictionary.GetEnumerator();

            Assert.False(dictionary.TryAdd("a", "c"));

            Assert.True(valuesEnum.MoveNext());
        }
        public void Clear_OnEmptyCollection_DoesNotInvalidateEnumerator()
        {
            if (ModifyEnumeratorAllowed.HasFlag(ModifyOperation.Clear))
            {
                IDictionary dictionary = new LinkedDictionary <string, string>();
                IEnumerator valuesEnum = dictionary.GetEnumerator();

                dictionary.Clear();
                Assert.Empty(dictionary);
                Assert.False(valuesEnum.MoveNext());
            }
        }
 public void LinkedDictionary_Generic_Remove_RemoveLastEnumerationFinishes()
 {
     if (ModifyEnumeratorAllowed.HasFlag(ModifyOperation.Remove))
     {
         LinkedDictionary <TKey, TValue> dict = (LinkedDictionary <TKey, TValue>)GenericIDictionaryFactory(3);
         TKey key = default;
         using (var enumerator = dict.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 key = enumerator.Current.Key;
             }
         }
         using (var enumerator = dict.GetEnumerator())
         {
             enumerator.MoveNext();
             enumerator.MoveNext();
             dict.Remove(key);
             Assert.False(enumerator.MoveNext());
         }
     }
 }
 public void LinkedDictionary_Generic_Remove_RemoveCurrentEnumerationContinues()
 {
     if (ModifyEnumeratorAllowed.HasFlag(ModifyOperation.Remove))
     {
         LinkedDictionary <TKey, TValue> dict = (LinkedDictionary <TKey, TValue>)GenericIDictionaryFactory(3);
         using (var enumerator = dict.GetEnumerator())
         {
             enumerator.MoveNext();
             enumerator.MoveNext();
             dict.Remove(enumerator.Current.Key);
             Assert.True(enumerator.MoveNext());
             Assert.False(enumerator.MoveNext());
         }
     }
 }