Esempio n. 1
0
        public void GetEnumerator_NoItems_EmptyEnumerator()
        {
            SqlBulkCopyColumnOrderHintCollection collection = CreateCollection();
            IEnumerator e = collection.GetEnumerator();

            Assert.Throws <InvalidOperationException>(() => e.Current);
            Assert.False(e.MoveNext());
            Assert.Throws <InvalidOperationException>(() => e.Current);
        }
Esempio n. 2
0
        public void GetEnumerator_ModifiedCollectionDuringEnumeration_ThrowsInvalidOperationException()
        {
            SqlBulkCopyColumnOrderHintCollection collection = CreateCollection();

            IEnumerator e = collection.GetEnumerator();

            collection.Add("column", SortOrder.Ascending);

            // Collection changed.
            Assert.Throws <InvalidOperationException>(() => e.MoveNext());
            Assert.Throws <InvalidOperationException>(() => e.Reset());
        }
Esempio n. 3
0
        public void GetEnumerator_ItemsAdded_AllItemsReturnedAndEnumeratorBehavesAsExpected()
        {
            var item1 = new SqlBulkCopyColumnOrderHint("column1", SortOrder.Ascending);
            var item2 = new SqlBulkCopyColumnOrderHint("column2", SortOrder.Descending);
            var item3 = new SqlBulkCopyColumnOrderHint("column3", SortOrder.Descending);

            SqlBulkCopyColumnOrderHintCollection collection = CreateCollection(item1, item2, item3);

            IEnumerator e = collection.GetEnumerator();

            const int Iterations = 2;

            for (int i = 0; i < Iterations; i++)
            {
                // Not started
                Assert.Throws <InvalidOperationException>(() => e.Current);

                Assert.True(e.MoveNext());
                Assert.Same(item1, e.Current);

                Assert.True(e.MoveNext());
                Assert.Same(item2, e.Current);

                Assert.True(e.MoveNext());
                Assert.Same(item3, e.Current);

                Assert.False(e.MoveNext());
                Assert.False(e.MoveNext());
                Assert.False(e.MoveNext());
                Assert.False(e.MoveNext());
                Assert.False(e.MoveNext());

                // Ended
                Assert.Throws <InvalidOperationException>(() => e.Current);

                e.Reset();
            }
        }