public void TestCollectionSync()
        {
            string item0 = "Item0";
            string item1 = "Item1";
            string item2 = "Item2";
            string item3 = "Item3";

            ObservableCollection<string> collection = new ObservableCollection<string>();

            HelperLabeledViewModelCollection viewModel = new HelperLabeledViewModelCollection(null, collection, o => o);

            collection.Add(item0);
            collection.Add(item1);
            collection.Add(item3);
            Assert.IsTrue(CompareCollectionValues(collection, viewModel), "Add did not work.");

            collection.Insert(2, item2);
            Assert.IsTrue(CompareCollectionValues(collection, viewModel), "Insert did not work.");

            collection.Remove(item3);
            Assert.IsTrue(CompareCollectionValues(collection, viewModel), "Remove did not work.");

            collection.Move(0, 1);
            Assert.IsTrue(CompareCollectionValues(collection, viewModel), "Move did not work.");

            collection.Clear();
            Assert.IsTrue(CompareCollectionValues(collection, viewModel), "Clear did not work.");
        }
        public static void InsertTest_Negative()
        {
            Guid[] anArray = { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            ObservableCollection<Guid> collection = new ObservableCollection<Guid>(anArray);
            ReadOnlyObservableCollection<Guid> readonlyCol = new ReadOnlyObservableCollection<Guid>(collection);
            ((INotifyCollectionChanged)readonlyCol).CollectionChanged += (o, e) => { throw new ShouldNotBeInvokedException(); };

            Guid itemToInsert = Guid.NewGuid();
            int[] iArrInvalidValues = new Int32[] { -1, -2, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000, Int32.MinValue };
            foreach (var index in iArrInvalidValues)
            {
                Assert.Throws<ArgumentOutOfRangeException>(() => collection.Insert(index, itemToInsert));
                Assert.Equal(anArray.Length, collection.Count);
            }

            int[] iArrLargeValues = new Int32[] { collection.Count + 1, Int32.MaxValue, Int32.MaxValue / 2, Int32.MaxValue / 10 };
            foreach (var index in iArrLargeValues)
            {
                Assert.Throws<ArgumentOutOfRangeException>(() => collection.Insert(index, itemToInsert));
                Assert.Equal(anArray.Length, collection.Count);
            }
        }
 internal static void AddDefaultHeadersFooters( ObservableCollection<DataTemplate> headersCollection, ObservableCollection<DataTemplate> footersCollection )
 {
   headersCollection.Insert( 0, DetailConfiguration.DefaultColumnManagerRowTemplate );
   headersCollection.Insert( 0, DetailConfiguration.DefaultHeaderSpacerTemplate );
 }
        private void UpdateFilters()
        {
            Log.Debug("Updating filters");

            if (_filterSchemes != null)
            {
                _filterSchemes.Schemes.CollectionChanged -= OnFilterSchemesCollectionChanged;
            }

            _filterSchemes = _filterSchemeManager.FilterSchemes;

            if (_filterSchemes != null)
            {
                _filterSchemes.Schemes.CollectionChanged += OnFilterSchemesCollectionChanged;
            }

            var newSchemes = new ObservableCollection<FilterScheme>();

            if (RawCollection == null)
            {
                _targetType = null;
            }
            else
            {
                _targetType = CollectionHelper.GetTargetType(RawCollection);
                if (_targetType != null)
                {
                    ((ICollection<FilterScheme>)newSchemes).AddRange((from scheme in _filterSchemes.Schemes
                                                                      where scheme.TargetType != null && _targetType.IsAssignableFromEx(scheme.TargetType)
                                                                      select scheme));
                }
            }

            newSchemes.Insert(0, NoFilterFilter);

            if (AvailableSchemes == null || !Catel.Collections.CollectionHelper.IsEqualTo(AvailableSchemes, newSchemes))
            {
                AvailableSchemes = newSchemes;

                var selectedFilter = _filterService.SelectedFilter ?? NoFilterFilter;
                SelectedFilterScheme = selectedFilter;
            }
        }
        public static void InsertTest_Negative()
        {
            Guid[] anArray = { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            ObservableCollection<Guid> collection = new ObservableCollection<Guid>(anArray);
            collection.CollectionChanged += (o, e) =>
            {
                Assert.True(false, "Should not have thrown collection changed event when removing items from invalid indices");
            };

            Guid itemToInsert = Guid.NewGuid();
            int[] iArrInvalidValues = new Int32[] { -1, -2, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000, Int32.MinValue };
            foreach (var index in iArrInvalidValues)
            {
                Assert.Throws<ArgumentOutOfRangeException>(() => collection.Insert(index, itemToInsert));
                Assert.Equal(anArray.Length, collection.Count);
            }

            int[] iArrLargeValues = new Int32[] { collection.Count + 1, Int32.MaxValue, Int32.MaxValue / 2, Int32.MaxValue / 10 };
            foreach (var index in iArrLargeValues)
            {
                Assert.Throws<ArgumentOutOfRangeException>(() => collection.Insert(index, itemToInsert));
                Assert.Equal(anArray.Length, collection.Count);
            }
        }
        public static void InsertTest()
        {
            Guid[] anArray = { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            ObservableCollection<Guid> col0 = new ObservableCollection<Guid>((IEnumerable<Guid>)anArray);
            ObservableCollection<Guid> col1 = new ObservableCollection<Guid>((IEnumerable<Guid>)anArray);
            ObservableCollection<Guid> col3 = new ObservableCollection<Guid>((IEnumerable<Guid>)anArray);

            //inserting item at the beginning.
            Guid g0 = Guid.NewGuid();
            col0.Insert(0, g0);
            Assert.Equal(g0, col0[0]);

            // inserting item in the middle
            Guid g1 = Guid.NewGuid();
            col1.Insert(1, g1);
            Assert.Equal(g1, col1[1]);

            // inserting item at the end.
            Guid g3 = Guid.NewGuid();
            col3.Insert(col3.Count, g3);
            Assert.Equal(g3, col3[col3.Count - 1]);

            string[] anArrayString = new string[] { "one", "two", "three", "four" };
            ObservableCollection<string> collection = new ObservableCollection<string>((IEnumerable<string>)anArrayString);
            CollectionAndPropertyChangedTester helper = new CollectionAndPropertyChangedTester();
            helper.AddOrInsertItemTest(collection, "seven", 2);
            helper.AddOrInsertItemTest(collection, "zero", 0);
            helper.AddOrInsertItemTest(collection, "eight", collection.Count);
        }
示例#7
0
		public void InsertItemBeforeSelection ()
		{
			var index = 2;
			var item = Items [index];
			var incc = new ObservableCollection<object>(Items);
			SetSource(incc);

			View.MoveCurrentToPosition(index);
			ResetCounters();
			incc.Insert(0, new object());

			Assert.AreEqual(index + 1, View.CurrentPosition, "#1");
			Assert.AreEqual(item, View.CurrentItem, "#2");
			Assert.AreEqual(0, CurrentChanged, "#3");
			Assert.AreEqual(0, CurrentChanging, "#4");
		}
示例#8
0
        //ObservableCollectionTest
        public static void ObservableCollectionTest()
        {
            var data = new ObservableCollection<string>();

            data.CollectionChanged += new NotifyCollectionChangedEventHandler(DataCollectionChanged);

            data.Add("One");
            data.Add("Two");
            data.Add("Three");
            data.Insert(1,"$^^$");
            data.RemoveAt(1);
            foreach (var tmp in data)
            {
                Console.WriteLine(tmp);
            }
        }
 void InsertLayoutDefinition(ObservableCollection<LayoutDefinition> list, LayoutDefinition layoutDef)
 {
     list.Insert(FindInsertIndexForDocumentFactory(list, layoutDef.DocumentFactoryName), layoutDef);
 }
        // ###################################################
        // CIDER-SPECIFIC CHANGE IN NEED OF PORTING - BEGIN
        // ###################################################

        // This method used to be non-virtual, private
        protected virtual void AddProperty(PropertyEntry property, ObservableCollection<PropertyEntry> unconsumedProperties, ObservableCollection<PropertyEntry> referenceOrder, ObservableCollection<CategoryEditor> categoryEditors)
        {

            // ###################################################
            // CIDER-SPECIFIC CHANGE IN NEED OF PORTING - END
            // ###################################################

            bool consumed = false;

            foreach (CategoryEditor categoryEditor in categoryEditors)
            {
                if (categoryEditor.ConsumesProperty(property))
                {
                    consumed = true;
                }
            }
            if (!consumed)
            {
                // We need to insert this property in the correct location.  Reference order is sorted and contains all properties in the unconsumed properties collection.
                Fx.Assert(referenceOrder.Contains(property), "Reference order should contain the property to be added.");
#if DEBUG
                foreach (PropertyEntry unconsumedProperty in unconsumedProperties)
                {
                    Fx.Assert(referenceOrder.Contains(unconsumedProperty), "Reference order should contain all unconsumed properties.");
                }
#endif

                // We'll walk both collections, and advance the insertion index whenever we see an unconsumed property come ahead of the target in the reference order.
                int referenceIndex = 0;
                int insertionIndex = 0;
                while (referenceOrder[referenceIndex] != property && insertionIndex < unconsumedProperties.Count)
                {
                    if (unconsumedProperties[insertionIndex] == referenceOrder[referenceIndex])
                    {
                        insertionIndex++;
                    }
                    referenceIndex++;
                }
                unconsumedProperties.Insert(insertionIndex, property);
            }
        }
        public void SetItemsSourceAndModifyCollection()
        {
            // Create the DataGrid and setup its binding
            ObservableCollection<string> strings = new ObservableCollection<string>() { "one", "two", "three" };
            bool isLoaded = false;
            DataGrid dataGrid = new DataGrid();
            dataGrid.Loaded += delegate { isLoaded = true; };

            // Set the ItemsSource and verify the slot counts
            dataGrid.ItemsSource = strings;
            dataGrid.SelectedIndex = 0;
            Assert.AreEqual(3, dataGrid.SlotCount, "Incorrect SlotCount after setting ItemsSource");
            Assert.AreEqual(3, dataGrid.VisibleSlotCount, "Incorrect VisibleSlotCount after setting ItemsSource");
            Assert.AreEqual(0, dataGrid.SelectedIndex, "SelectedIndex incorrect");

            // Remove an item and verify that the DataGrid is updated
            strings.RemoveAt(1);
            Assert.AreEqual(2, dataGrid.SlotCount, "Incorrect SlotCount after removing an item");
            Assert.AreEqual(2, dataGrid.VisibleSlotCount, "Incorrect VisibleSlotCount after removing an item");
            Assert.AreEqual(0, dataGrid.SelectedIndex, "SelectedIndex incorrect after removing an item");

            // Add an item and verify that the DataGrid is updated
            strings.Add("four");
            Assert.AreEqual(3, dataGrid.SlotCount, "Incorrect SlotCount after adding an item");
            Assert.AreEqual(3, dataGrid.VisibleSlotCount, "Incorrect VisibleSlotCount after adding an item");
            Assert.AreEqual(0, dataGrid.SelectedIndex, "SelectedIndex incorrect after adding an item");

            // Insert an item an dverify that the DataGrid is updated
            strings.Insert(0, "zero");
            Assert.AreEqual(4, dataGrid.SlotCount, "Incorrect SlotCount after inserting an item");
            Assert.AreEqual(4, dataGrid.VisibleSlotCount, "Incorrect VisibleSlotCount after inserting an item");
            Assert.AreEqual(1, dataGrid.SelectedIndex, "SelectedIndex incorrect after inserting an item");

            // Add the DataGrid to the visual tree
            TestPanel.Children.Add(dataGrid);
            this.EnqueueConditional(delegate { return isLoaded; });

            this.EnqueueYieldThread();
            this.EnqueueCallback(delegate
            {
                Assert.AreEqual(4, dataGrid.SlotCount, "Incorrect SlotCount after adding and removing items");
                Assert.AreEqual(4, dataGrid.VisibleSlotCount, "Incorrect VisibleSlotCount after adding and removing items");
                Assert.AreEqual(1, dataGrid.SelectedIndex, "SelectedIndex was not updated when collection changed");
                Assert.AreEqual("one", dataGrid.SelectedItem, "SelectedItem was not updated when collection changed");

                DataGridRow row = dataGrid.DisplayData.GetDisplayedRow(0);
                Assert.IsNotNull(row);
                Assert.AreEqual(0, row.Slot, "Incorrect Row.Slot");
                Assert.AreEqual(0, row.Index, "Incorrect Row.Index");
                Assert.AreEqual("zero", row.DataContext, "Incorrect Row.DataContext");

                row = dataGrid.DisplayData.GetDisplayedRow(1);
                Assert.IsNotNull(row);
                Assert.AreEqual(1, row.Slot, "Incorrect Row.Slot");
                Assert.AreEqual(1, row.Index, "Incorrect Row.Index");
                Assert.AreEqual("one", row.DataContext, "Incorrect Row.DataContext");

                row = dataGrid.DisplayData.GetDisplayedRow(2);
                Assert.IsNotNull(row);
                Assert.AreEqual(2, row.Slot, "Incorrect Row.Slot");
                Assert.AreEqual(2, row.Index, "Incorrect Row.Index");
                Assert.AreEqual("three", row.DataContext, "Incorrect Row.DataContext");

                row = dataGrid.DisplayData.GetDisplayedRow(3);
                Assert.IsNotNull(row);
                Assert.AreEqual(3, row.Slot, "Incorrect Row.Slot");
                Assert.AreEqual(3, row.Index, "Incorrect Row.Index");
                Assert.AreEqual("four", row.DataContext, "Incorrect Row.DataContext");
            });
            this.EnqueueTestComplete();
        }
示例#12
0
        // keep inner and outer CollViews' GroupDescription collections in synch 
        private void SynchronizeGroupDescriptions(NotifyCollectionChangedEventArgs e, ObservableCollection<GroupDescription> origin, ObservableCollection<GroupDescription> clone)
        { 
            if (clone == null)
                return;             // the clone might be lazily-created _groupBy

            int i; 

            switch (e.Action) 
            { 
                case NotifyCollectionChangedAction.Add:
                    Debug.Assert(e.NewStartingIndex >= 0); 
                    if (clone.Count + e.NewItems.Count != origin.Count)
                        goto case NotifyCollectionChangedAction.Reset;
                    for (i = 0; i < e.NewItems.Count; i++)
                    { 
                        clone.Insert(e.NewStartingIndex + i, (GroupDescription) e.NewItems[i]);
                    } 
                    break; 

                case NotifyCollectionChangedAction.Remove: 
                    Debug.Assert(e.OldStartingIndex >= 0);
                    if (clone.Count - e.OldItems.Count != origin.Count)
                        goto case NotifyCollectionChangedAction.Reset;
                    for (i = 0; i < e.OldItems.Count; i++) 
                    {
                        clone.RemoveAt(e.OldStartingIndex); 
                    } 
                    break;
 
                case NotifyCollectionChangedAction.Replace:
                    Debug.Assert(e.OldStartingIndex >= 0);
                    if (clone.Count + e.NewItems.Count - e.OldItems.Count != origin.Count)
                        goto case NotifyCollectionChangedAction.Reset; 
                    // If there are as many new items as old items, then
                    // this is a straight replace. 
                    if (e.OldItems.Count == e.NewItems.Count) 
                    {
                        for (i = 0; i < e.OldItems.Count; i++) 
                        {
                            clone[e.OldStartingIndex + i] = (GroupDescription) e.NewItems[i];
                        }
                    } 
                    else
                    { 
                        for (i = 0; i < e.OldItems.Count; i++) 
                        {
                            clone.RemoveAt(e.OldStartingIndex); 
                        }
                        for (i = 0; i < e.NewItems.Count; i++)
                        {
                            clone.Insert(e.NewStartingIndex + i, (GroupDescription) e.NewItems[i]); 
                        }
                    } 
                    break; 

                case NotifyCollectionChangedAction.Move: 
                    Debug.Assert(e.OldStartingIndex >= 0);
                    if (clone.Count != origin.Count)
                        goto case NotifyCollectionChangedAction.Reset;
                    if (e.OldItems.Count == 1) 
                    {
                        clone.Move(e.OldStartingIndex, e.NewStartingIndex); 
                    } 
                    else
                    { 
                        if (e.NewStartingIndex < e.OldStartingIndex)
                        {
                            for (i = 0; i < e.OldItems.Count; i++)
                            { 
                                clone.Move(e.OldStartingIndex + i, e.NewStartingIndex + i);
                            } 
                        } 
                        else if (e.NewStartingIndex > e.OldStartingIndex)
                        { 
                            for (i = e.OldItems.Count - 1; i >= 0; i--)
                            {
                                clone.Move(e.OldStartingIndex + i, e.NewStartingIndex + i);
                            } 
                        }
                    } 
                    break; 

                // this arm also handles cases where the two collections have gotten 
                // out of [....] (typically because exceptions prevented a previous [....]
                // from happening)
                case NotifyCollectionChangedAction.Reset:
                    CloneList(clone, origin); 
                    break;
                default: 
                    throw new NotSupportedException(SR.Get(SRID.UnexpectedCollectionChangeAction, e.Action)); 
            }
        } 
示例#13
0
 /// <summary>
 /// 
 /// </summary>
 public void LoadSubSidiary()
 {
     if (KmtConstants.IsOemCorp || KmtConstants.IsTpiCorp)
     {
         Subsidiarys = new ObservableCollection<Subsidiary>(ssProxy.GetSubsidiaries());
         Subsidiarys.Insert(0, new Subsidiary() { SsId = 0, DisplayName = MergedResources.Common_All });
         //Select 'Show All' on First Load
         SelectedSubSidiary = Subsidiarys.FirstOrDefault();
     }
     else// Factory Floor
         Subsidiarys = new ObservableCollection<Subsidiary>();
 }
        internal void MakeRootDesigner(ModelItem modelItem, bool setAsSelection, bool checkIfCanBeMadeRoot)
        {
            ModelItem currentRootModelItem = (this.RootDesigner != null) ? ((WorkflowViewElement)this.RootDesigner).ModelItem : null;
            if (modelItem == currentRootModelItem)
            {
                return;
            }
            if (typeof(ActivityBuilder).IsAssignableFrom(modelItem.ItemType))
            {
                this.ActivitySchema = modelItem;
            }

            WorkflowViewService viewService = this.Context.Services.GetService<ViewService>() as WorkflowViewService;

            //try get designer for given model item
            Type designerType = viewService.GetDesignerType(modelItem.ItemType);
            //if one doesn't exist - check its parent tree, perhaps there will be one
            while (null == designerType && null != modelItem.Parent)
            {
                modelItem = modelItem.Parent;
                designerType = viewService.GetDesignerType(modelItem.ItemType);
            }

            if (viewService.ShouldAppearOnBreadCrumb(modelItem, checkIfCanBeMadeRoot))
            {
                UpdateAncestorFlag(currentRootModelItem, modelItem);
                Dictionary<ModelItem, ModelItem> newSelectionMap = new Dictionary<ModelItem, ModelItem>();
                ModelItem newRootModelItem = modelItem;
                ObservableCollection<object> breadCrumbCollection = new ObservableCollection<object>();
                object breadCrumbObjectConnector = null;
                bool isFirstAdded = false;
                while (modelItem != null)
                {
                    bool shouldCheckIfCanBeMadeRoot = true;
                    if (isFirstAdded)
                    {
                        shouldCheckIfCanBeMadeRoot = checkIfCanBeMadeRoot;
                    }
                    if (viewService.ShouldAppearOnBreadCrumb(modelItem, shouldCheckIfCanBeMadeRoot))
                    {
                        if (isFirstAdded)
                        {
                            breadCrumbObjectConnector = new BreadCrumbObjectSeparator();
                            breadCrumbCollection.Insert(0, breadCrumbObjectConnector);
                        }
                        breadCrumbCollection.Insert(0, modelItem);
                        isFirstAdded = true;
                        if (selectionMap.ContainsKey(modelItem))
                        {
                            newSelectionMap.Add(modelItem, selectionMap[modelItem]);
                        }
                    }
                    modelItem = modelItem.Parent;
                }

                //Remember the selection for the current root.
                WorkflowViewElement focusedElement = Keyboard.FocusedElement as WorkflowViewElement;
                //This condition will be true when we are breadcrumbing into a child element.
                if (focusedElement != null && object.Equals(focusedElement.ModelItem, newRootModelItem))
                {
                    if (currentRootModelItem != null)
                    {
                        newSelectionMap[currentRootModelItem] = newRootModelItem;
                    }
                }
                this.selectionMap = newSelectionMap;
                SetAsRootDesignerView(newRootModelItem, setAsSelection);
                breadCrumbListBox.ItemsSource = breadCrumbCollection;
                // Move to the top left so that the display name is visible.
                this.ScrollViewer.ScrollToTop();
                this.ScrollViewer.ScrollToLeftEnd();
            }
        }
        /// <summary>
        /// Will perform an Add or Insert on the given Collection depending on whether the 
        /// insertIndex is null or not. If it is null, will Add, otherwise, will Insert.
        /// </summary>
        public void AddOrInsertItemTest(ReadOnlyObservableCollection<string> readOnlyCol, ObservableCollection<string> collection,
            string itemToAdd, int? insertIndex = null)
        {
            INotifyPropertyChanged readOnlyPropertyChanged = readOnlyCol;
            readOnlyPropertyChanged.PropertyChanged += Collection_PropertyChanged;
            _expectedPropertyChanged = new[]
            {
                new PropertyNameExpected(COUNT),
                new PropertyNameExpected(ITEMARRAY)
            };

            INotifyCollectionChanged readOnlyCollectionChanged = readOnlyCol;
            readOnlyCollectionChanged.CollectionChanged += Collection_CollectionChanged;
            _expectedCollectionChangedFired++;
            _expectedAction = NotifyCollectionChangedAction.Add;
            _expectedNewItems = new string[] { itemToAdd };
            if (insertIndex.HasValue)
                _expectedNewStartingIndex = insertIndex.Value;
            else
                _expectedNewStartingIndex = collection.Count;
            _expectedOldItems = null;
            _expectedOldStartingIndex = -1;

            int expectedCount = collection.Count + 1;

            if (insertIndex.HasValue)
            {
                collection.Insert(insertIndex.Value, itemToAdd);
                Assert.Equal(itemToAdd, readOnlyCol[insertIndex.Value]);
            }
            else
            {
                collection.Add(itemToAdd);
                Assert.Equal(itemToAdd, readOnlyCol[collection.Count - 1]);
            }

            Assert.Equal(expectedCount, readOnlyCol.Count);
            Assert.Equal(_expectedCollectionChangedFired, _numCollectionChangedFired);

            foreach (var item in _expectedPropertyChanged)
                Assert.True(item.IsFound, "The propertychanged event should have fired for" + item.Name + ", since we just added an item");

            readOnlyCollectionChanged.CollectionChanged -= Collection_CollectionChanged;
            readOnlyPropertyChanged.PropertyChanged -= Collection_PropertyChanged;
        }
示例#16
0
        static void data_SectionStoriesDownloadCompleted(object sender,
                                                        DownloadStringCompletedEventArgs downloadCompletedEvent,
                                                        ObservableCollection<Story> storyCollection,
                                                        Section section,
                                                        InsertStoriesAt insertStoriesAt)
        {
            if (downloadCompletedEvent.Error != null)
            {
                DownloadFailed(sender, downloadCompletedEvent);
                return;
            }

            SunApiAdapter.handleJsonWithSanitization(
                (json) =>
                {
                    var stories = SunApiAdapter.StoriesOfApiResponse(json);
                    var existingNids = storyCollection.Select(s => s.Nid);
                    int countStoriesAdded = insertStoriesAt == InsertStoriesAt.Beginning ? 0 : storyCollection.Count;
                    foreach (Story story in stories.Where(article => !existingNids.Contains(article.Nid)))
                    {
                        story.Vid = section.Vid;

                        // cached stories will already be present
                        // so we want to add the new stuff to the beginning
                        // Do we need to sort anyway, or will this always work?
                        storyCollection.Insert(countStoriesAdded++, story);
                    }
                },
                () =>
                {
                    Debug.Assert(false, "Why couldn't the JSON be parsed?");
                    DownloadFailed(sender, downloadCompletedEvent);
                },
                downloadCompletedEvent.Result
            );
        }
 public void Test_ObservableCollection_Add()
 {
     var list = new ObservableCollection<int>();
     Assert.Equal(0, list.Count);
     list.Add(3);
     Assert.Equal(1, list.Count);
     Assert.Equal(3, list[0]);
     list.Add(4);
     Assert.Equal(2, list.Count);
     Assert.Equal(4, list[1]);
     list.Insert(0, 5);
     Assert.Equal(3, list.Count);
     Assert.Equal(5, list[0]);
     Assert.Equal(3, list[1]);
     Assert.Equal(4, list[2]);
     list.Insert(2, 6);
     Assert.Equal(4, list.Count);
     Assert.Equal(5, list[0]);
     Assert.Equal(3, list[1]);
     Assert.Equal(6, list[2]);
     Assert.Equal(4, list[3]);
     list.CollectionChanged += (o, e) =>
     {
         Assert.Same(list, o);
         Assert.Equal(NotifyCollectionChangedAction.Add, e.Action);
         Assert.Null(e.OldItems);
         Assert.NotNull(e.NewItems);
         Assert.Equal(1, e.NewItems.Count);
         Assert.Equal(7, e.NewItems[0]);
     };
     list.Add(7);
     list = new ObservableCollection<int>() { 3 };
     list.CollectionChanged += (o, e) =>
     {
         Assert.Same(list, o);
         Assert.Equal(NotifyCollectionChangedAction.Add, e.Action);
         Assert.Null(e.OldItems);
         Assert.NotNull(e.NewItems);
         Assert.Equal(1, e.NewItems.Count);
         Assert.Equal(7, e.NewItems[0]);
     };
     list.Insert(0, 7);
 }