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_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());
         }
     }
 }
 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());
         }
     }
 }