Exemple #1
0
        public void Test_GetEnumerator()
        {
            var a = LIST.GetEnumerator();
            var b = _view.GetEnumerator();

            while (a.MoveNext())
            {
                b.MoveNext();
                Assert.AreEqual(a.Current, b.Current);
            }
        }
        public void GroupsEnumeratorTest()
        {
            CollectionView.GroupDescriptions.Add(new PropertyGroupDescription("StringProperty"));

            // Test the Enumerator on the Groups
            IEnumerator groupEnumerator = CollectionView.GetEnumerator();

            int count = 0;

            while (groupEnumerator.MoveNext())
            {
                Assert.AreEqual(CollectionView[count], groupEnumerator.Current);
                count++;
            }
        }
        public void GetEnumeratorTest()
        {
            // check that we get the correct item for each index in the source collection
            IEnumerator enumerator = CollectionView.GetEnumerator();

            foreach (TestClass item in SourceCollection)
            {
                enumerator.MoveNext();
                Assert.AreEqual(item, enumerator.Current);
            }

            // check that when we have paging, the enumerator only returns the items on
            // the current page
            CollectionView.PageSize = 5;
            int count = 0;

            enumerator = CollectionView.GetEnumerator();
            while (enumerator.MoveNext())
            {
                count++;
            }
            Assert.AreEqual(5, count);

            // verify that when we have grouping, we will still fetch the correct items
            // from the group to enumerate through
            CollectionView.GroupDescriptions.Add(new PropertyGroupDescription("IntProperty"));

            count      = 0;
            enumerator = CollectionView.GetEnumerator();
            while (enumerator.MoveNext())
            {
                // show that we are getting the items from the correct group
                Assert.AreEqual(1, (enumerator.Current as TestClass).IntProperty);
                count++;
            }
            Assert.AreEqual(5, count);
        }