public void CannotDeferRefresh()
        {
            ObservableCollection <TestClass> collection = new ObservableCollection <TestClass>()
            {
                new TestClass()
            };
            PagedCollectionView pcv = new PagedCollectionView(collection);

            // show that we will throw an exception if we try to change the PageSize while adding
            pcv.AddNew();
            PagedCollectionViewTest.AssertExpectedException(
                new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringAddOrEdit, "DeferRefresh")),
                delegate
            {
                pcv.DeferRefresh();
            });
            pcv.CancelNew();

            // show that we will throw an exception if we try to change the PageSize while editing
            pcv.EditItem(pcv[0]);
            PagedCollectionViewTest.AssertExpectedException(
                new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringAddOrEdit, "DeferRefresh")),
                delegate
            {
                pcv.DeferRefresh();
            });
        }
        public void CountTestWithNoItems()
        {
            List <int>          intList = new List <int>();
            PagedCollectionView pcv     = new PagedCollectionView(intList);

            Assert.AreEqual(0, pcv.Count);

            // update the PageSize and verify that we still have a Count of 0.
            pcv.PageSize = 10;
            Assert.AreEqual(0, pcv.Count);

            // update the PageSize during a DeferRefresh and verify that we still have a Count of 0.
            pcv.PageSize = 0;
            using (pcv.DeferRefresh())
            {
                pcv.PageSize = 10;
                pcv.MoveToPage(1);
            }
            Assert.AreEqual(0, pcv.Count);

            // now try those same tests above with grouping
            pcv.GroupDescriptions.Add(new PropertyGroupDescription(""));
            pcv.PageSize = 0;
            Assert.AreEqual(0, pcv.Count);

            // update the PageSize and verify that we still have a Count of 0.
            pcv.PageSize = 10;
            Assert.AreEqual(0, pcv.Count);

            // update the PageSize during a DeferRefresh and verify that we still have a Count of 0.
            pcv.PageSize = 0;
            using (pcv.DeferRefresh())
            {
                pcv.PageSize = 5;
            }
            Assert.AreEqual(0, pcv.Count);
        }