public void Write_RemoveElementAtIndex_ElementRemoved() { var col = new ConcurrentObservableCollection <string>(new[] { "a", "b", "c" }); col.RemoveAt(1); CollectionAssert.AreEqual(new[] { "a", "c" }, col); }
public async Task WriteInConcurrentObservableCollectionUIThread() { using (var collection = new ConcurrentObservableCollection <int>()) { _collectionChangedCount = 0; collection.CollectionChanged += Collection_CollectionChanged; await TaskHelper.RunOnUIThreadAsync(() => { for (int i = 1; i < 10000; i++) { for (int j = 1; j < 10; j++) { collection.Add(i *j); } collection.RemoveAt(collection.Count - 1); collection.Remove(i); collection.Move(0, 6); collection.Insert(0, i *i); } }).ConfigureAwait(false); Assert.AreEqual(79992, collection.Count); Assert.AreEqual(129987, _collectionChangedCount); } }
public void Write_RemoveElementAtIndex_ElementRemoved() { var col = new ConcurrentObservableCollection <string>(new[] { "a", "b", "c" }); col.RemoveAt(1); col.Should().BeEquivalentTo("a", "c"); }
public void Write_ComplexOperation_CollectionUpdatedProperly() { var col = new ConcurrentObservableCollection <string>(new[] { "a", "b", "c" }); col.Add("d"); col.Remove("b"); col.Insert(0, "x"); col.AddRange(new[] { "z", "f", "y" }); col.RemoveAt(4); col.RemoveRange(new[] { "y", "c" }); col[2] = "p"; CollectionAssert.AreEquivalent(new[] { "x", "a", "p", "f" }, col); }
public void Init() { UIEvents.CollectionChanged += (sender, args) => { for (int i = 0; i < UIEvents.Count; i++) { if (UIEvents[i].IsCompleted()) { UIEvents.RemoveAt(i); } else { UIEvents[i].PerformAction(); } } return; }; }