Пример #1
0
		public void BeginUpdate()
		{
			ViewFactory factory = ViewFactory.IBindingListINotifyPropertyChangedItems();
			ObjectListView view = factory.View;
			IList 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);
		}
Пример #2
0
		public void ListChangedItemReplacedAndUpdated()
		{
			BindingList<NotifyingListItem> list = new BindingList<NotifyingListItem>();

			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)));

			ObjectListView view = new ObjectListView(list);
			SetupListEventHandlers(view);

			NotifyingListItem item = new NotifyingListItem(50, "555", new DateTime(1955, 5, 5));
			list[2] = item;
			Assert.AreEqual(1, this.listChangedItemChangedRaised);

			item.IntegerValue = 60;
			Assert.AreEqual(2, this.listChangedItemChangedRaised);
		}
Пример #3
0
		public void ListChangedNotifyingItemChanged()
		{
			BindingList<NotifyingListItem> list = new BindingList<NotifyingListItem>();
			NotifyingListItem item = new NotifyingListItem();
			list.Add(item);

			ObjectListView view = new ObjectListView(list);
			this.SetupListEventHandlers(view);

			Assert.AreEqual(0, this.listChangedAddedRaised);
			Assert.AreEqual(0, this.listChangedDeletedRaised);
			Assert.AreEqual(0, this.listChangedItemChangedRaised);
			Assert.AreEqual(0, this.listChangedResetRaised);

			item.IntegerValue++;

			Assert.AreEqual(0, this.listChangedAddedRaised);
			Assert.AreEqual(0, this.listChangedDeletedRaised);
			Assert.AreEqual(1, this.listChangedItemChangedRaised);
			Assert.AreEqual(0, this.listChangedResetRaised);
		}
Пример #4
0
		public void FilterPredicateVaryingListItemProperties()
		{
			ViewFactory factory = ViewFactory.IBindingListINotifyPropertyChangedItems();
			ObjectListView view = factory.View;
			IList 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.ItemType = typeof(NotifyingListItem);

			view.FilterPredicate = delegate(object listItem) { return ((NotifyingListItem)listItem).IntegerValue < 3; };
			Assert.AreEqual(2, view.Count);

			changingItem.IntegerValue = 0;
			Assert.AreEqual(3, view.Count);
		}
Пример #5
0
		public void EndUpdateWithoutChanges()
		{
			ViewFactory factory = ViewFactory.IBindingListINotifyPropertyChangedItems();
			ObjectListView view = factory.View;

			NotifyingListItem item = new NotifyingListItem();

			view.Add(item);
			item.IntegerValue = 9;

			factory.ClearEventCounts();

			view.BeginUpdate();
			view.EndUpdate();

			Assert.AreEqual(0, factory.ListChangedResetCount);
		}