Example #1
0
        public void EnsureCapacity_Generic_RequestingLargerCapacity_DoesNotInvalidateEnumeration(int setLength)
        {
            LinkedHashSet <T> set      = (LinkedHashSet <T>)(GenericISetFactory(setLength));
            var         capacity       = set.EnsureCapacity(0);
            IEnumerator valuesEnum     = set.GetEnumerator();
            IEnumerator valuesListEnum = new SCG.List <T>(set).GetEnumerator();

            set.EnsureCapacity(capacity + 1); // Verify EnsureCapacity does not invalidate enumeration

            while (valuesEnum.MoveNext())
            {
                valuesListEnum.MoveNext();
                Assert.Equal(valuesListEnum.Current, valuesEnum.Current);
            }
        }