public void BeginUpdate() { ViewFactory<NotifyingListItem> factory = ViewFactory<NotifyingListItem>.IBindingList(); ObjectListView<NotifyingListItem> view = factory.View; IList<NotifyingListItem> list = factory.List; view.BeginUpdate(); NotifyingListItem item = new NotifyingListItem(); view.Add(item); // normally would raise ListChanged (ItemAdded) item.IntegerValue = 9; // normally would raise ListChanged (ItemChanged, reflecting PropertyChanged) Assert.AreEqual(0, factory.ListChangedAddedCount); Assert.AreEqual(0, factory.ListChangedItemChangedCount); view.EndUpdate(); Assert.AreEqual(0, factory.ListChangedAddedCount); Assert.AreEqual(0, factory.ListChangedItemChangedCount); Assert.AreEqual(1, factory.ListChangedResetCount); }
public void EndUpdateWithoutBeginUpdate() { ViewFactory<NotifyingListItem> factory = ViewFactory<NotifyingListItem>.IBindingList(); ObjectListView<NotifyingListItem> view = factory.View; NotifyingListItem item = new NotifyingListItem(); view.Add(item); item.IntegerValue = 9; Assert.AreEqual(1, factory.ListChangedAddedCount); Assert.AreEqual(1, factory.ListChangedItemChangedCount); view.EndUpdate(); Assert.AreEqual(1, factory.ListChangedAddedCount); Assert.AreEqual(1, factory.ListChangedItemChangedCount); Assert.AreEqual(0, factory.ListChangedResetCount); }
public void FilterPredicateVaryingListItemProperties() { ViewFactory<NotifyingListItem> factory = ViewFactory <NotifyingListItem>.IBindingList(); ObjectListView<NotifyingListItem> view = factory.View; IList<NotifyingListItem> list = factory.List; list.Add(new NotifyingListItem(1, "aaa", DateTime.Now)); list.Add(new NotifyingListItem(2, "bbb", DateTime.Now)); NotifyingListItem changingItem = new NotifyingListItem(3, "ccc", DateTime.Now); list.Add(changingItem); list.Add(new NotifyingListItem(4, "ddd", DateTime.Now)); list.Add(new NotifyingListItem(5, "eee", DateTime.Now)); view.FilterPredicate = delegate(NotifyingListItem listItem) { return listItem.IntegerValue < 3; }; Assert.AreEqual(2, view.Count); changingItem.IntegerValue = 0; Assert.AreEqual(3, view.Count); }
public void ListChangedItemReplacedAndUpdated() { ViewFactory<NotifyingListItem> factory = ViewFactory<NotifyingListItem>.IBindingList(); IList<NotifyingListItem> list = factory.List; list.Add(new NotifyingListItem(100, "aaa", new DateTime(1970, 1, 1))); list.Add(new NotifyingListItem(80, "bbb", new DateTime(1980, 12, 12))); list.Add(new NotifyingListItem(60, "ccc", new DateTime(1975, 6, 6))); factory.ClearEventCounts(); NotifyingListItem item = new NotifyingListItem(50, "555", new DateTime(1955, 5, 5)); list[2] = item; Assert.AreEqual(1, factory.ListChangedItemChangedCount); item.IntegerValue = 60; Assert.AreEqual(2, factory.ListChangedItemChangedCount); }
public void ListChangedNotifyingItemChanged() { BindingList<NotifyingListItem> list = new BindingList<NotifyingListItem>(); NotifyingListItem item = new NotifyingListItem(); list.Add(item); ViewFactory<NotifyingListItem> factory = ViewFactory<NotifyingListItem>.IBindingList(list); factory.ClearEventCounts(); Assert.AreEqual(0, factory.ListChangedAddedCount); Assert.AreEqual(0, factory.ListChangedDeletedCount); Assert.AreEqual(0, factory.ListChangedItemChangedCount); Assert.AreEqual(0, factory.ListChangedResetCount); item.IntegerValue++; Assert.AreEqual(0, factory.ListChangedAddedCount); Assert.AreEqual(0, factory.ListChangedDeletedCount); Assert.AreEqual(1, factory.ListChangedItemChangedCount); Assert.AreEqual(0, factory.ListChangedResetCount); }
public void ListChangedItemChangedOutOfFilter() { ViewFactory<NotifyingListItem> factory = ViewFactory<NotifyingListItem>.IBindingList(); ObjectListView<NotifyingListItem> view = factory.View; IList<NotifyingListItem> list = factory.List; list.Add(new NotifyingListItem(1, "aaa", DateTime.Now)); list.Add(new NotifyingListItem(5, "bbb", DateTime.Now)); list.Add(new NotifyingListItem(5, "ccc", DateTime.Now)); NotifyingListItem ddd = new NotifyingListItem(2, "ddd", DateTime.Now); list.Add(ddd); list.Add(new NotifyingListItem(5, "eee", DateTime.Now)); view.Filter = "IntegerValue < 5"; factory.ClearEventCounts(); ddd.IntegerValue = 6; Assert.AreEqual(0, factory.ListChangedItemChangedCount); Assert.AreEqual(1, factory.ListChangedDeletedCount); }