コード例 #1
0
        public void PageSizeWithAddEditTest()
        {
            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // add a new item
                TestClass newItem = CollectionView.AddNew() as TestClass;
                Assert.IsTrue(CollectionView.IsAddingNew);

                CollectionView.CurrentChanged += new EventHandler(CommitAddOrEditOperation);

                // verify that we can update the PageSize and that the add operation is committed
                CollectionView.PageSize = 10;
                Assert.AreEqual(10, CollectionView.PageSize);
                Assert.IsFalse(CollectionView.IsAddingNew);

                CollectionView.CurrentChanged -= new EventHandler(CommitAddOrEditOperation);

                // now edit an item
                CollectionView.EditItem(CollectionView[0]);
                Assert.IsTrue(CollectionView.IsEditingItem);

                CollectionView.CurrentChanged += new EventHandler(CommitAddOrEditOperation);

                // verify that we can update the PageSize and that the edit operation is committed
                CollectionView.PageSize = 5;
                Assert.AreEqual(5, CollectionView.PageSize);
                Assert.IsFalse(CollectionView.IsEditingItem);

                CollectionView.CurrentChanged -= new EventHandler(CommitAddOrEditOperation);
            }
        }
コード例 #2
0
        public void ItemCountTest()
        {
            // we should have 25 items initially
            Assert.AreEqual(25, CollectionView.ItemCount);

            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // our count should increase when we add items
                TestClass newItem = CollectionView.AddNew() as TestClass;
                CollectionView.CommitNew();
                Assert.AreEqual(26, CollectionView.ItemCount);

                // and it should decrease when we remove items
                CollectionView.Remove(newItem);
                CollectionView.RemoveAt(0);
                Assert.AreEqual(24, CollectionView.ItemCount);

                // item count shows the total items we hold onto in our
                // collection, so even if we page, it is unaffected
                CollectionView.PageSize = 5;
                Assert.AreEqual(24, CollectionView.ItemCount);
            }
        }
コード例 #3
0
        public void EditItemTest()
        {
            // initially we should not be editing anything
            Assert.IsFalse(CollectionView.IsEditingItem);

            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // test that we cannot edit a new item that has not been
                // committed yet
                object item = CollectionView.AddNew();
                CollectionView.EditItem(item);
                Assert.IsFalse(CollectionView.IsEditingItem);
                Assert.IsTrue(CollectionView.IsAddingNew);
                CollectionView.CommitNew();

                // however, we can edit other items other than the new item.
                // this will force a commit on the new item and start editing
                // the other item
                CollectionView.AddNew();
                object editItem = CollectionView[0];
                CollectionView.EditItem(editItem);
                Assert.AreEqual(editItem, CollectionView.CurrentEditItem);
                Assert.IsTrue(CollectionView.IsEditingItem);
                Assert.IsFalse(CollectionView.IsAddingNew);
                CollectionView.CommitEdit();
            }
        }
コード例 #4
0
        public void InsertAndRemoveGroupsTest()
        {
            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // set group description and verify that the items get grouped in this order
                CollectionView.GroupDescriptions.Add(new PropertyGroupDescription("StringProperty"));

                // currently there should be groups "A" and "B"
                Assert.AreEqual(2, CollectionView.Groups.Count);

                // insert a new item and verify that a new group is created
                TestClass newItem = CollectionView.AddNew() as TestClass;
                newItem.StringProperty = "C";
                CollectionView.CommitNew();

                // verify that we now have an additional group and that it appears at the end
                Assert.AreEqual(3, CollectionView.Groups.Count);
                Assert.AreEqual(25, CollectionView.IndexOf(newItem));

                // now remove that item (since it is the only one in its group) and verify that
                // the group is removed
                CollectionView.Remove(newItem);
                Assert.AreEqual(2, CollectionView.Groups.Count);
                Assert.IsFalse(CollectionView.Contains(newItem));
            }
        }
コード例 #5
0
        public void CommitEditTest()
        {
            // verify that once we commit the data after an edit, the CollectionView
            // contains the updated values
            TestClass editItem = CollectionView[0] as TestClass;

            CollectionView.EditItem(editItem);
            editItem.IntProperty    = 0;
            editItem.StringProperty = "Edit";
            CollectionView.CommitEdit();
            Assert.AreEqual(0, (CollectionView[0] as TestClass).IntProperty);
            Assert.AreEqual("Edit", (CollectionView[0] as TestClass).StringProperty);

            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // verify that we cannot call CommitEdit during an AddNew operation
                CollectionView.AddNew();
                AssertExpectedException(
                    new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringTransaction, "CommitEdit", "AddNew")),
                    delegate
                {
                    CollectionView.CommitEdit();
                });
            }
        }
コード例 #6
0
        public void RemoveTest()
        {
            // verify the the count gets updated when we remove items
            TestClass removeItem = CollectionView[0] as TestClass;

            Assert.AreEqual(25, CollectionView.Count);
            Assert.IsTrue(CollectionView.Contains(removeItem));
            CollectionView.Remove(removeItem);
            Assert.AreEqual(24, CollectionView.Count);
            Assert.IsFalse(CollectionView.Contains(removeItem));

            // verify that we cannot call Remove/RemoveAt during an Edit
            CollectionView.EditItem(CollectionView[0]);
            AssertExpectedException(
                new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringAddOrEdit, "RemoveAt")),
                delegate
            {
                CollectionView.RemoveAt(0);
            });

            // verify that we also cannot call Remove/RemoveAt during an Add
            CollectionView.AddNew();
            AssertExpectedException(
                new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringAddOrEdit, "RemoveAt")),
                delegate
            {
                CollectionView.RemoveAt(0);
            });
        }
コード例 #7
0
        public void CountTest()
        {
            // we should have 25 items initially
            Assert.AreEqual(25, CollectionView.Count);

            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // our count should increase when we add items
                TestClass newItem = CollectionView.AddNew() as TestClass;
                CollectionView.CommitNew();
                Assert.AreEqual(26, CollectionView.Count);

                // and it should decrease when we remove items
                CollectionView.Remove(newItem);
                CollectionView.RemoveAt(0);
                Assert.AreEqual(24, CollectionView.Count);

                // when we add paging, it should display just the items on
                // the current page
                CollectionView.PageSize = 5;
                Assert.AreEqual(5, CollectionView.Count);

                // if we move to the last page, it will display the number
                // of items on that page (which is less than the page size)
                CollectionView.MoveToLastPage();
                Assert.AreEqual(4, CollectionView.Count);

                // add grouping and test
                CollectionView.GroupDescriptions.Add(new PropertyGroupDescription("IntProperty"));
                CollectionView.MoveToFirstPage();
                Assert.AreEqual(5, CollectionView.Count);

                // get the count of items in the group
                int count = 0;
                for (int i = 0; i < CollectionView.Groups.Count; i++)
                {
                    count += (CollectionView.Groups[i] as CollectionViewGroup).ItemCount;
                }
                Assert.AreEqual(CollectionView.Count, count);

                // remove paging and test again
                CollectionView.PageSize = 0;
                Assert.AreEqual(24, CollectionView.Count);

                // get the count of items in the group
                count = 0;
                for (int i = 0; i < CollectionView.Groups.Count; i++)
                {
                    count += (CollectionView.Groups[i] as CollectionViewGroup).ItemCount;
                }
                Assert.AreEqual(CollectionView.Count, count);
            }
        }
コード例 #8
0
 public void CurrencyWithAddNew()
 {
     // if we don't implement IList, we cannot run the rest of
     // the test as we cannot add/remove items
     if (this.ImplementsIList)
     {
         // whenever we add a new item through the AddNew() method
         // currency gets set to the new item
         TestClass item = CollectionView.AddNew() as TestClass;
         Assert.AreEqual(item, CollectionView.CurrentItem);
     }
 }
コード例 #9
0
        public void CurrentAddItemTest()
        {
            // verify that the property is null when we are not adding
            Assert.IsNull(CollectionView.CurrentAddItem);

            // add a new item and verify that the property is set
            object newItem = CollectionView.AddNew();

            Assert.AreEqual(newItem, CollectionView.CurrentAddItem);

            // verify that once we are done adding, the property will revert to null
            CollectionView.CancelNew();
            Assert.IsNull(CollectionView.CurrentAddItem);
        }
コード例 #10
0
        public void CanAddNewTest()
        {
            // verify that we can add items into our collection view
            Assert.IsTrue(CollectionView.CanAddNew);

            // verify that we are not allowed to add a new item while we are still editing
            CollectionView.EditItem(CollectionView[0]);
            Assert.IsFalse(CollectionView.CanAddNew);
            CollectionView.CommitEdit();
            Assert.IsTrue(CollectionView.CanAddNew);

            // verify that when we are adding a new item, we can add another
            CollectionView.AddNew();
            Assert.IsTrue(CollectionView.CanAddNew);
        }
コード例 #11
0
        public void CurrencyWithPagingTest()
        {
            // set a page size
            CollectionView.PageSize = 5;

            // verify that when we call AddNew, the new item gets currency
            TestClass newItem = CollectionView.AddNew() as TestClass;

            Assert.AreEqual(newItem, CollectionView.CurrentItem);

            // verify that after we commit, we still have currency
            CollectionView.CommitNew();
            Assert.AreEqual(newItem, CollectionView.CurrentItem);
            Assert.AreEqual(CollectionView.IndexOf(newItem), CollectionView.CurrentPosition);
        }
コード例 #12
0
        public void AddNewOnFilteredCollection()
        {
            // add a filter to the collection
            CollectionView.Filter = FilterOutOnes;

            // now add an item and verify that it is added as the last item
            object addItem = CollectionView.AddNew();

            Assert.AreEqual(CollectionView.Count - 1, CollectionView.IndexOf(addItem));
            CollectionView.CancelNew();

            // verify that this holds for paging as well
            CollectionView.PageSize = 10;
            addItem = CollectionView.AddNew();
            Assert.AreEqual(CollectionView.Count - 1, CollectionView.IndexOf(addItem));
        }
コード例 #13
0
        public void CancelNewTest()
        {
            // assert that the count is updated when we add a new item
            // and that the item is within the view.
            Assert.AreEqual(25, CollectionView.Count);
            TestClass addItem = CollectionView.AddNew() as TestClass;

            Assert.AreEqual(26, CollectionView.Count);
            Assert.IsTrue(CollectionView.IndexOf(addItem) >= 0);

            // now verify that when we cancel teh add, the item no longer
            // appears in the view and the count is decremented.
            CollectionView.CancelNew();
            Assert.AreEqual(25, CollectionView.Count);
            Assert.IsFalse(CollectionView.IndexOf(addItem) >= 0);
        }
コード例 #14
0
        public void CanRemoveTest()
        {
            // verify that we can add items into our collection view
            Assert.IsTrue(CollectionView.CanRemove);

            // verify that when we are adding a new item, we cannot remove items
            CollectionView.AddNew();
            Assert.IsFalse(CollectionView.CanRemove);
            CollectionView.CommitNew();
            Assert.IsTrue(CollectionView.CanRemove);

            // verify that while we are still editing, we cannot remove items
            CollectionView.EditItem(CollectionView[0]);
            Assert.IsFalse(CollectionView.CanRemove);
            CollectionView.CommitEdit();
            Assert.IsTrue(CollectionView.CanRemove);
        }
コード例 #15
0
        public void IEditableObject()
        {
            // we only want to run this test for items that implement IEditableObject
            // and where the source collection won't handle the editing first
            EditableTestClass editItem = CollectionView[0] as EditableTestClass;

            if (editItem == null)
            {
                return;
            }

            // check that the debug string has not been set
            Assert.IsNull(editItem.DebugString);

            // verify that BeginEdit was called on the IEditable interface
            CollectionView.EditItem(editItem);
            Assert.AreEqual("BeginEdit", editItem.DebugString);

            // verify that CancelEdit was called on the IEditable interface
            CollectionView.CancelEdit();
            Assert.AreEqual("CancelEdit", editItem.DebugString);

            // verify that EndEdit was called on the IEditable interface
            CollectionView.EditItem(editItem);
            CollectionView.CommitEdit();
            Assert.AreEqual("EndEdit", editItem.DebugString);

            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // verify that when adding a new item, it will call BeginEdit on it
                editItem = CollectionView.AddNew() as EditableTestClass;
                Assert.AreEqual("BeginEdit", editItem.DebugString);

                // verify that when canceling the new item, it will call CancelEdit on it.
                CollectionView.CancelNew();
                Assert.AreEqual("CancelEdit", editItem.DebugString);

                // verify that when committing a new item, it will call EndEdit on it.
                editItem = CollectionView.AddNew() as EditableTestClass;
                CollectionView.CommitNew();
                Assert.AreEqual("EndEdit", editItem.DebugString);
            }
        }
コード例 #16
0
        public void CanCancelEditTest()
        {
            object editItem = CollectionView[0];

            CollectionView.EditItem(CollectionView[0]);

            if (editItem is IEditableObject)
            {
                Assert.IsTrue(CollectionView.CanCancelEdit);

                // if we don't implement IList, we cannot run the rest of
                // the test as we cannot add/remove items
                if (this.ImplementsIList)
                {
                    // verify that we cannot call CommitEdit during an AddNew operation
                    CollectionView.AddNew();
                    AssertExpectedException(
                        new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringTransaction, "CancelEdit", "AddNew")),
                        delegate
                    {
                        CollectionView.CancelEdit();
                    });
                    CollectionView.CommitNew();
                }

                // if we are not editing trying to CancelEdit will throw
                if (!CollectionView.CanCancelEdit)
                {
                    AssertExpectedException(
                        new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.CancelEditNotSupported)),
                        delegate
                    {
                        CollectionView.CancelEdit();
                    });
                }
            }
            else
            {
                // if our collection does not implement IEditableCollection
                // and our data does not impelement IEditableObject, then we
                // cannot cancel an edit, as we do not have the old data cached
                Assert.IsFalse(CollectionView.CanCancelEdit);
            }
        }
コード例 #17
0
        public void CurrencyTest()
        {
            // verify that when we call AddNew, the new item gets currency
            TestClass newItem = CollectionView.AddNew() as TestClass;

            Assert.AreEqual(newItem, CollectionView.CurrentItem);
            Assert.AreEqual(CollectionView.IndexOf(newItem), CollectionView.CurrentPosition);
            CollectionView.CommitNew();
            Assert.AreEqual(newItem, CollectionView.CurrentItem);
            Assert.AreEqual(CollectionView.IndexOf(newItem), CollectionView.CurrentPosition);

            // verify that we can set currency to another item in between the AddNew/CommitNew
            newItem = CollectionView.AddNew() as TestClass;
            Assert.AreEqual(newItem, CollectionView.CurrentItem);
            Assert.AreEqual(CollectionView.IndexOf(newItem), CollectionView.CurrentPosition);
            CollectionView.MoveCurrentToFirst();
            CollectionView.CommitNew();
            Assert.AreNotEqual(newItem, CollectionView.CurrentItem);
            Assert.AreNotEqual(CollectionView.IndexOf(newItem), CollectionView.CurrentPosition);

            // add sorting and paging
            CollectionView.SortDescriptions.Add(new SortDescription("IntProperty", ListSortDirection.Ascending));
            CollectionView.PageSize = 5;
            CollectionView.MoveToLastPage();

            // add a new item that would get moved to a different page
            newItem             = CollectionView.AddNew() as TestClass;
            newItem.IntProperty = 2;
            CollectionView.CommitNew();

            // verify that the last item on the page gets currency
            Assert.AreEqual(CollectionView[CollectionView.Count - 1], CollectionView.CurrentItem);
            Assert.AreEqual(CollectionView.Count - 1, CollectionView.CurrentPosition);

            // try setting the currency to null after a AddNew and verify that on commit
            // the currency will stay at null.
            CollectionView.AddNew();
            CollectionView.MoveCurrentTo(null);
            CollectionView.CommitNew();
            Assert.IsNull(CollectionView.CurrentItem);
        }
コード例 #18
0
        public void SortingTest()
        {
            // add a sort description to the collection view
            CollectionView.SortDescriptions.Add(new SortDescription("IntProperty", ListSortDirection.Ascending));

            // add a new item and verify that it does not get moved until we commit
            TestClass newItem = CollectionView.AddNew() as TestClass;

            Assert.AreEqual(25, CollectionView.IndexOf(newItem));
            newItem.IntProperty = 0;
            Assert.AreEqual(25, CollectionView.IndexOf(newItem));

            // now commit - the item should move to the top due to sorting
            CollectionView.CommitNew();
            Assert.AreEqual(0, CollectionView.IndexOf(newItem));

            // now combine with paging
            CollectionView.PageSize = 5;
            CollectionView.MoveToPage(1);

            // verify that adding a new item will still preserve the
            // count, as we have a page size constraint
            Assert.AreEqual(5, CollectionView.Count);
            newItem = CollectionView.AddNew() as TestClass;
            Assert.AreEqual(5, CollectionView.Count);

            // now set a value that will make the item move out of the
            // page once committed.
            newItem.IntProperty = 0;
            Assert.IsTrue(CollectionView.IndexOf(newItem) >= 0);
            CollectionView.CommitNew();
            Assert.IsFalse(CollectionView.IndexOf(newItem) >= 0);

            // now try editing an item and setting a value where it will stay
            // on the current page
            CollectionView.MoveToFirstPage();
            newItem = CollectionView.AddNew() as TestClass;
            Assert.IsTrue(CollectionView.IndexOf(newItem) >= 0);
            CollectionView.CommitNew();
            Assert.IsTrue(CollectionView.IndexOf(newItem) >= 0);
        }
コード例 #19
0
        public void GroupingTest()
        {
            // add a group description to the collection view
            CollectionView.GroupDescriptions.Add(new PropertyGroupDescription("IntProperty"));

            // add a new item and verify that it does not get moved until we commit
            TestClass newItem = CollectionView.AddNew() as TestClass;

            Assert.AreEqual(25, CollectionView.IndexOf(newItem));
            newItem.IntProperty    = 1;
            newItem.StringProperty = "C";
            Assert.AreEqual(25, CollectionView.IndexOf(newItem));

            // it should get moved to the end of the first group once we commit
            CollectionView.CommitNew();
            Assert.AreEqual(5, CollectionView.IndexOf(newItem));

            // now add paging and add a new item. verify that it will stay
            // on the current page until we commit
            CollectionView.PageSize = 5;
            newItem                = CollectionView.AddNew() as TestClass;
            newItem.IntProperty    = 5;
            newItem.StringProperty = "C";
            Assert.AreEqual(4, CollectionView.IndexOf(newItem));

            // now commit, and the item will move out of this page
            CollectionView.CommitNew();
            Assert.IsFalse(CollectionView.IndexOf(newItem) >= 0);

            // now add sorting and try adding a new item
            CollectionView.SortDescriptions.Add(new SortDescription("StringProperty", ListSortDirection.Ascending));
            newItem                = CollectionView.AddNew() as TestClass;
            newItem.IntProperty    = 1;
            newItem.StringProperty = "";
            Assert.AreEqual(4, CollectionView.IndexOf(newItem));

            // when we commit, this time the sorting should move the item into the top
            // of the first group
            CollectionView.CommitNew();
            Assert.AreEqual(0, CollectionView.IndexOf(newItem));
        }
コード例 #20
0
        public void IsAddingNewTest()
        {
            // verify that the property is false when we are not adding
            Assert.IsFalse(CollectionView.IsAddingNew);

            // add a new item and verify that the property is set
            CollectionView.AddNew();
            Assert.IsTrue(CollectionView.IsAddingNew);

            // verify that once we are cancel adding, the property will revert to false
            CollectionView.CancelNew();
            Assert.IsFalse(CollectionView.IsAddingNew);

            // add an item again
            CollectionView.AddNew();
            Assert.IsTrue(CollectionView.IsAddingNew);

            // verify that once we are commit the add, the property will revert to false
            CollectionView.CommitNew();
            Assert.IsFalse(CollectionView.IsAddingNew);
        }
コード例 #21
0
        public void AddNewTest()
        {
            // verify the the count gets updated when we add items
            Assert.AreEqual(25, CollectionView.Count);
            CollectionView.AddNew();
            Assert.AreEqual(26, CollectionView.Count);
            CollectionView.CommitNew();
            Assert.AreEqual(26, CollectionView.Count);

            // verify that we can call an AddNew, when there is already
            // an add in progress (it will commit the previous add and
            // start a new add).
            object addItem = CollectionView.AddNew();

            CollectionView.AddNew();
            Assert.AreNotEqual(addItem, CollectionView.CurrentAddItem);
            CollectionView.CommitNew();
            Assert.AreEqual(28, CollectionView.Count);

            // also the same applies for when we edit items. by calling
            // AddNew, we will commit the edit and start a new add operation
            CollectionView.EditItem(CollectionView[0]);
            Assert.IsTrue(CollectionView.IsEditingItem);
            addItem = CollectionView.AddNew();
            Assert.IsFalse(CollectionView.IsEditingItem);
            Assert.AreEqual(addItem, CollectionView.CurrentAddItem);
            CollectionView.CancelNew();

            // verify that AddNew succeeds even on empty collections that
            // implement IEnumerable<T>
            Assert.IsTrue(CollectionView.CanRemove);
            while (CollectionView.Count > 0)
            {
                CollectionView.RemoveAt(0);
            }
            addItem = CollectionView.AddNew();
            Assert.IsNotNull(addItem);
            CollectionView.CancelNew();
        }
コード例 #22
0
        public void GroupingWithAddTest()
        {
            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // set group description and verify that the items get grouped in this order
                CollectionView.GroupDescriptions.Add(new PropertyGroupDescription("StringProperty"));

                // currently there should be groups "A" and "B"
                Assert.AreEqual(2, CollectionView.Groups.Count);

                // insert a new item and verify that it gets placed into the right group
                TestClass newItem = CollectionView.AddNew() as TestClass;
                newItem.StringProperty = "A";
                CollectionView.CommitNew();


                Assert.AreEqual(2, CollectionView.Groups.Count);
                Assert.AreEqual(13, CollectionView.IndexOf(newItem));
                Assert.IsTrue((CollectionView.Groups[0] as CollectionViewGroup).Items.Contains(newItem));
            }
        }
コード例 #23
0
        public void PagingWithAddNewTest()
        {
            // add paging
            CollectionView.PageSize = 5;

            // add a new item and check that it is the last item on this page
            object addItem = CollectionView.AddNew();

            Assert.AreEqual(CollectionView.PageSize - 1, CollectionView.IndexOf(addItem));

            // now commit and verify that it stayed in the same position
            CollectionView.CommitNew();
            Assert.AreEqual(CollectionView.PageSize - 1, CollectionView.IndexOf(addItem));

            // move to the next page and test the same thing
            CollectionView.MoveToNextPage();
            addItem = CollectionView.AddNew();
            Assert.AreEqual(CollectionView.PageSize - 1, CollectionView.IndexOf(addItem));

            // now commit and verify that it stayed in the same position
            CollectionView.CommitNew();
            Assert.AreEqual(CollectionView.PageSize - 1, CollectionView.IndexOf(addItem));
        }
コード例 #24
0
        public void AddNewWithUnsyncedCollection()
        {
            // this issue should only affect source collections that do not
            // implement INotifyCollectionChanged, but we can still run the
            // test for all collections.
            IList sourceCollection = CollectionView.SourceCollection as IList;

            // first add items to the source collection, which should get the
            // collection out of sync with the internal list if it doesn't
            // implement INotifyCollectionChanged.
            if (sourceCollection != null)
            {
                for (int i = 0; i < 10; i++)
                {
                    sourceCollection.Add(new EditableTestClass());
                }
            }

            // now try to call AddNew and verify that we will get it added at the correct index
            // 25 (original items) + 10 (loop) + 1 (add new) = 36 (count) - 1 (for zero based index) = 35
            object newItem = CollectionView.AddNew();

            Assert.AreEqual(35, CollectionView.IndexOf(newItem));
        }
コード例 #25
0
        public void CancelCurrentChangingDuringPageSizeUpdate()
        {
            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                CollectionView.CurrentChanging += new CurrentChangingEventHandler(CancelCurrentChanging);

                // add a new item
                TestClass newItem = CollectionView.AddNew() as TestClass;
                Assert.IsTrue(CollectionView.IsAddingNew);

                // verify that because the currency change is cancelled, we do not continue and throw
                PagedCollectionViewTest.AssertExpectedException(
                    new InvalidOperationException(PagedCollectionViewResources.ChangingPageSizeNotAllowedDuringAddOrEdit),
                    delegate
                {
                    CollectionView.PageSize = 10;
                });


                // now edit an item
                CollectionView.EditItem(CollectionView[0]);
                Assert.IsTrue(CollectionView.IsEditingItem);

                // verify that because the currency change is cancelled, we do not continue and throw
                PagedCollectionViewTest.AssertExpectedException(
                    new InvalidOperationException(PagedCollectionViewResources.ChangingPageSizeNotAllowedDuringAddOrEdit),
                    delegate
                {
                    CollectionView.PageSize = 10;
                });

                CollectionView.CurrentChanging -= new CurrentChangingEventHandler(CancelCurrentChanging);
            }
        }
コード例 #26
0
        public void PagingTest()
        {
            // set up sorting and paging
            CollectionView.SortDescriptions.Add(new System.ComponentModel.SortDescription("IntProperty", System.ComponentModel.ListSortDirection.Ascending));
            CollectionView.PageSize = 5;

            TestClass editItem = CollectionView[0] as TestClass;

            CollectionView.EditItem(editItem);

            CollectionView.CurrentChanging += new CurrentChangingEventHandler(CollectionView_PagingTestCurrentChanging);

            this._cancelCurrencyMove = true;

            // verify that we cannot change pages because the collection view cancels the move
            // in the CurrentChanging event handler.
            Assert.IsFalse(CollectionView.MoveToNextPage());
            Assert.IsFalse(CollectionView.MoveToPreviousPage());

            this._cancelCurrencyMove = false;

            // verify that we can change pages even though the current item is edited.
            Assert.IsTrue(CollectionView.MoveToNextPage());

            // Editing was committed before the page move.
            Assert.IsFalse(CollectionView.IsEditingItem);

            this._cancelCurrencyMove = null;

            // Move back to the first page.
            Assert.IsTrue(CollectionView.MoveToFirstPage());

            // Edit the first item again.
            editItem = CollectionView[0] as TestClass;
            CollectionView.EditItem(editItem);

            // verify that the item is still on the same page after we update
            // the values, as we have not committed the change yet
            editItem.IntProperty = 100;
            Assert.AreEqual(0, CollectionView.IndexOf(editItem));

            // verify that after we commit, the item is moved off the page
            // and that we can change pages.
            CollectionView.CommitEdit();
            Assert.AreEqual(-1, CollectionView.IndexOf(editItem));
            Assert.IsTrue(CollectionView.MoveToNextPage());
            Assert.IsTrue(CollectionView.MoveToPreviousPage());

            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // Begin an addition transaction.
                CollectionView.AddNew();

                // Do not allow page moves.
                this._cancelCurrencyMove = true;
                Assert.IsFalse(CollectionView.MoveToNextPage());

                // Addition is still in progress.
                Assert.IsTrue(CollectionView.IsAddingNew);

                // verify that we can change pages even though an addition is in progress.
                this._cancelCurrencyMove = false;
                Assert.IsTrue(CollectionView.MoveToNextPage());

                // Addition was committed before the page move.
                Assert.IsFalse(CollectionView.IsAddingNew);
            }

            CollectionView.CurrentChanging -= new CurrentChangingEventHandler(CollectionView_PagingTestCurrentChanging);
        }
コード例 #27
0
        public void NewItemWithListBoxTest()
        {
            CollectionView.SortDescriptions.Add(new System.ComponentModel.SortDescription("IntProperty", System.ComponentModel.ListSortDirection.Ascending));
            CollectionView.PageSize = 6;

            ListBox lb = new ListBox();

            lb.ItemsSource = CollectionView;

            this.CreateAsyncTask(
                lb,
                delegate
            {
                // ------------------------------------
                // |Page | 0  | 1  | 2  | 3  | 4  | 5  |
                // ------------------------------------
                // | 0   | 1  | 2  | 3  | 4  | 5  | 6  |
                // | 1   | 7  | 8  | 9  | 10 | 11 | 12 |
                // | 2   | 13 | 14 | 15 | 16 | 17 | 18 |
                // | 3   | 19 | 20 | 21 | 22 | 23 | 24 |
                // | 4   | 25 |    |    |    |    |    |
                // ------------------------------------
                Assert.AreEqual(6, lb.Items.Count);
                CollectionView.MoveToLastPage();
                Assert.AreEqual(1, lb.Items.Count);

                // ------------------------------------
                // |Page | 0  | 1  | 2  | 3  | 4  | 5  |
                // ------------------------------------
                // | 0   | 1  | 2  | 3  | 4  | 5  | 6  |
                // | 1   | 7  | 8  | 9  | 10 | 11 | 12 |
                // | 2   | 13 | 14 | 15 | 16 | 17 | 18 |
                // | 3   | 19 | 20 | 21 | 22 | 23 | 24 |
                // | 4   | 25 |-26-|    |    |    |    |
                // ------------------------------------
                TestClass item      = CollectionView.AddNew() as TestClass;
                item.IntProperty    = 6;
                item.StringProperty = "F";
                Assert.AreEqual(2, lb.Items.Count);
                CollectionView.CommitNew();
                Assert.AreEqual(item, lb.Items[1]);

                // ------------------------------------
                // |Page | 0  | 1  | 2  | 3  | 4  | 5  |
                // ------------------------------------
                // | 0   | 1  | 2  | 3  | 4  | 5  | 6  |
                // | 1   | 7  | 8  | 9  | 10 | 11 | 12 | <-- move to this page
                // | 2   | 13 | 14 | 15 | 16 | 17 | 18 |
                // | 3   | 19 | 20 | 21 | 22 | 23 | 24 |
                // | 4   | 25 | 26 |    |    |    |    |
                // ------------------------------------
                CollectionView.MoveToPage(1);
                item                = CollectionView.AddNew() as TestClass;
                item.IntProperty    = 6;
                item.StringProperty = "F";
                Assert.AreEqual(6, lb.Items.Count);
                Assert.IsTrue(lb.Items.Contains(item));

                // after we commit, due to sorting, the item
                // will move to the last page
                CollectionView.CommitNew();
                Assert.AreEqual(6, lb.Items.Count);
                Assert.IsFalse(lb.Items.Contains(item));
            });

            EnqueueTestComplete();
        }
コード例 #28
0
        public void CurrencyWithPaging()
        {
            // add paging and move the currency to the first item
            CollectionView.PageSize = 5;
            CollectionView.MoveCurrentToFirst();
            TestClass item = CollectionView[0] as TestClass;

            Assert.AreEqual(item, CollectionView.CurrentItem);
            Assert.AreEqual(0, CollectionView.CurrentPosition);

            // change the page and verify that the currency events get fired
            // currency should be set to null and then to the first item on the next page
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Reset"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.MoveToNextPage();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreNotEqual(item, CollectionView.CurrentItem);
            Assert.AreEqual(0, CollectionView.CurrentPosition);

            // if we don't implement IList, we cannot run the rest of
            // the test as we cannot add/remove items
            if (this.ImplementsIList)
            {
                // if we have an add/edit operation currently taking place,
                // verify that it will get committed and that we will update
                // the currency when moving pages. we will change currency
                // twice, as we first set currency to null and then because
                // we did not commit the new operation, we will cancel the
                // page move and stay on the current page.
                item = CollectionView.AddNew() as TestClass;
                Assert.AreEqual(item, CollectionView.CurrentItem);
                _expectedEventQueue.Clear();

                _expectedEventQueue.Add(new EventNotification()
                {
                    EventType = "CurrentChanging"
                });
                _expectedEventQueue.Add(new EventNotification()
                {
                    EventType = "CurrentChanged"
                });
                _expectedEventQueue.Add(new EventNotification()
                {
                    EventType = "CurrentChanged"
                });
                Assert.AreEqual(1, CollectionView.PageIndex);
                CollectionView.MoveToNextPage();

                // verify that we stay on the same page and that we are still adding the new item
                Assert.IsTrue(CollectionView.IsAddingNew);
                Assert.AreEqual(1, CollectionView.PageIndex);
                Assert.AreEqual(0, _expectedEventQueue.Count);
                Assert.AreEqual(item, CollectionView.CurrentItem);
                Assert.AreEqual(4, CollectionView.CurrentPosition);
            }
        }
コード例 #29
0
        public void FilteredAddItemTest()
        {
            // apply a filter to the CollectionView
            CollectionView.Filter = FilterNegativeNumbers;
            Assert.AreEqual(25, CollectionView.Count);

            // add the item and set the IntProperty to a negative
            // number. before we commit, it should stay in the view
            TestClass addItem = CollectionView.AddNew() as TestClass;

            addItem.IntProperty = -1;
            Assert.AreEqual(26, CollectionView.Count);
            Assert.IsTrue(CollectionView.IndexOf(addItem) >= 0);

            // now commit to verify that it gets filtered out of the view
            // also verify that the correct events get fired
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(25, CollectionView.Count);
            Assert.IsFalse(CollectionView.IndexOf(addItem) >= 0);

            // verify that the currency has moved to a different item
            Assert.AreEqual(24, CollectionView.CurrentPosition);
            Assert.AreNotEqual(addItem, CollectionView.CurrentItem);

            // try adding paging and run through the same test
            // the only differnce should be that we add in a new item
            // to replace the one that got filtered out of the current page
            CollectionView.PageSize = 5;

            addItem             = CollectionView.AddNew() as TestClass;
            addItem.IntProperty = -1;
            Assert.AreEqual(5, CollectionView.Count);
            Assert.IsTrue(CollectionView.IndexOf(addItem) >= 0);

            // now commit to verify that it gets filtered out of the view
            // also verify that the correct events get fired
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Add"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(5, CollectionView.Count);
            Assert.IsFalse(CollectionView.IndexOf(addItem) >= 0);

            // also, try this on the last page to verify that a new item is not brought in
            CollectionView.RemoveAt(CollectionView.Count - 1);
            CollectionView.MoveToLastPage();
            Assert.AreEqual(4, CollectionView.Count);

            addItem             = CollectionView.AddNew() as TestClass;
            addItem.IntProperty = -1;
            Assert.AreEqual(5, CollectionView.Count);
            Assert.IsTrue(CollectionView.IndexOf(addItem) >= 0);

            // now commit to verify that it gets filtered out of the view
            // also verify that the correct events get fired
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(4, CollectionView.Count);
            Assert.IsFalse(CollectionView.IndexOf(addItem) >= 0);

            // now add grouping, move to the first page, and run
            // through the scenario again
            CollectionView.GroupDescriptions.Add(new PropertyGroupDescription("IntProperty"));
            CollectionView.MoveToFirstPage();
            addItem             = CollectionView.AddNew() as TestClass;
            addItem.IntProperty = -1;
            Assert.AreEqual(5, CollectionView.Count);
            Assert.IsTrue(CollectionView.IndexOf(addItem) >= 0);

            // now commit to verify that it gets filtered out of the view
            // also verify that the correct events get fired
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Add"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(5, CollectionView.Count);
            Assert.IsFalse(CollectionView.IndexOf(addItem) >= 0);

            // now try the same thing on the last page. we should get
            // a remove event, but not an add
            CollectionView.MoveToLastPage();
            addItem             = CollectionView.AddNew() as TestClass;
            addItem.IntProperty = -1;
            Assert.AreEqual(5, CollectionView.Count);
            Assert.IsTrue(CollectionView.IndexOf(addItem) >= 0);

            // now commit to verify that it gets filtered out of the view
            // also verify that the correct events get fired
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(4, CollectionView.Count);
            Assert.IsFalse(CollectionView.IndexOf(addItem) >= 0);
        }
コード例 #30
0
        public void EventsTest()
        {
            // begin adding an item - when we call AddNew, it sets
            // currency to the new item.
            _propertyChangedTracked = true;
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "PropertyChanged", Parameter = "ItemCount"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Add"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "PropertyChanged", Parameter = "Count"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "PropertyChanged", Parameter = "IsAddingNew"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "PropertyChanged", Parameter = "CurrentAddItem"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            TestClass addItem = CollectionView.AddNew() as TestClass;

            _propertyChangedTracked = false;
            Assert.AreEqual(0, _expectedEventQueue.Count);
            addItem.IntProperty    = 5;
            addItem.StringProperty = "A";

            // because we have no sorting, filtering, grouping, or paging, we should
            // not have to remove any items  from the view during an add. currency
            // should also be unchanged for this first test.
            this.AssertNoEvent(delegate { CollectionView.CommitNew(); });

            // we will add sorting now. this will remove and add the item back
            // in when we commit
            CollectionView.SortDescriptions.Add(new SortDescription("IntProperty", ListSortDirection.Ascending));
            addItem                = CollectionView.AddNew() as TestClass;
            addItem.IntProperty    = 5;
            addItem.StringProperty = "B";

            // make sure that we fire the remove/add, and also the currency events
            _propertyChangedTracked = true;
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "PropertyChanged", Parameter = "IsAddingNew"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "PropertyChanged", Parameter = "CurrentAddItem"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "PropertyChanged", Parameter = "Count"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Add"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "PropertyChanged", Parameter = "Count"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            _propertyChangedTracked = false;
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(26, CollectionView.CurrentPosition);

            // add an item that will move with sorting to test the currency changes.
            addItem                = CollectionView.AddNew() as TestClass;
            addItem.IntProperty    = 4;
            addItem.StringProperty = "A";

            // make sure that we fire the remove/add, once we commit and that the currency
            // events are again fired
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Add"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(16, CollectionView.CurrentPosition);

            // now add in paging and edit the item so that it will be moved
            // to a different page upon committing.
            CollectionView.PageSize = 5;
            addItem                = CollectionView.AddNew() as TestClass;
            addItem.IntProperty    = 5;
            addItem.StringProperty = "C";

            // again, make sure that we fire the remove/add, and update the currency
            // when the new item moves out.
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Add"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(4, CollectionView.CurrentPosition);
            Assert.AreNotEqual(addItem, CollectionView.CurrentItem);

            // now add and edit the values so that it should stay on the first page.
            addItem                = CollectionView.AddNew() as TestClass;
            addItem.IntProperty    = 0;
            addItem.StringProperty = "A";

            // make sure that we fire the remove/add, and update the currency
            // as the new item has moved within the page.
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Add"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(0, CollectionView.CurrentPosition);
            Assert.AreEqual(addItem, CollectionView.CurrentItem);

            // now add grouping and test editing so that it should remain on the same page.
            CollectionView.GroupDescriptions.Add(new PropertyGroupDescription("IntProperty"));
            addItem                = CollectionView.AddNew() as TestClass;
            addItem.IntProperty    = 0;
            addItem.StringProperty = "B";

            // make sure that we fire the remove/add, and update the currency
            // as the new item has moved within the page.
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Add"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(0, CollectionView.CurrentPosition);
            Assert.AreEqual(addItem, CollectionView.CurrentItem);

            // now add an item that will move off the current page
            addItem                = CollectionView.AddNew() as TestClass;
            addItem.IntProperty    = 5;
            addItem.StringProperty = "D";

            // make sure that we fire the remove/add, and update the currency
            // as the new item has moved within the page.
            _expectedEventQueue.Clear();
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Remove"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanging"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CollectionChanged", Parameter = "Add"
            });
            _expectedEventQueue.Add(new EventNotification()
            {
                EventType = "CurrentChanged"
            });
            CollectionView.CommitNew();
            Assert.AreEqual(0, _expectedEventQueue.Count);
            Assert.AreEqual(4, CollectionView.CurrentPosition);
            Assert.AreNotEqual(addItem, CollectionView.CurrentItem);
        }