Example #1
0
        public void IList_Generic_CurrentAtEnd_AfterAdd(int count)
        {
            if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
            {
                SCG.IList <T> collection = GenericIListFactory(count);

                using (SCG.IEnumerator <T> enumerator = collection.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ;                           // Go to end of enumerator
                    }
                    T current = default(T);
                    if (Enumerator_Current_UndefinedOperation_Throws)
                    {
                        Assert.Throws <InvalidOperationException>(() => enumerator.Current); // enumerator.Current should fail
                    }
                    else
                    {
                        current = enumerator.Current;
                        Assert.Equal(default(T), current);
                    }

                    // Test after add
                    int seed = 3538963;
                    for (int i = 0; i < 3; i++)
                    {
                        collection.Add(CreateT(seed++));

                        if (Enumerator_Current_UndefinedOperation_Throws)
                        {
                            Assert.Throws <InvalidOperationException>(() => enumerator.Current); // enumerator.Current should fail
                        }
                        else
                        {
                            current = enumerator.Current;
                            Assert.Equal(default(T), current);
                        }
                    }
                }
            }
        }