public void ClearItemsUsesDispatcherToRaiseEvents() { var collection = new BindableCollection <Element>() { new Element() }; bool propertyChangedRaised = false; ((INotifyPropertyChanged)collection).PropertyChanged += (o, e) => propertyChangedRaised = true; bool collectionChangingRaised = false; collection.CollectionChanging += (o, e) => collectionChangingRaised = true; bool collectionChangedRaised = false; collection.CollectionChanged += (o, e) => collectionChangedRaised = true; var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.Clear(); Assert.False(propertyChangedRaised); Assert.False(collectionChangingRaised); Assert.False(collectionChangedRaised); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.True(propertyChangedRaised); Assert.True(collectionChangingRaised); Assert.True(collectionChangedRaised); }
public void InsertItemUsesDispatcherToInsertItem() { var collection = new BindableCollection <Element>(); var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.Add(new Element()); Assert.AreEqual(0, collection.Count); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.AreEqual(1, collection.Count); }
public void RemoveRangeUsesDispatcherToRemoveElements() { var itemsToRemove = new[] { new Element(), new Element() }; var existingItems = new[] { new Element() }; var collection = new BindableCollection<Element>(itemsToRemove.Concat(existingItems)); var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.RemoveRange(itemsToRemove); Assert.That(collection, Is.EquivalentTo(itemsToRemove.Concat(existingItems))); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.AreEqual(existingItems, collection); }
public void RemoveRangeUsesDispatcherToRemoveElements() { var itemsToRemove = new[] { new Element(), new Element() }; var existingItems = new[] { new Element() }; var collection = new BindableCollection <Element>(itemsToRemove.Concat(existingItems)); var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.RemoveRange(itemsToRemove); Assert.That(collection, Is.EquivalentTo(itemsToRemove.Concat(existingItems))); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.AreEqual(existingItems, collection); }
public void ClearItemsUsesDispatcherToClearItems() { var collection = new BindableCollection <Element>() { new Element() }; var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.Clear(); Assert.AreEqual(1, collection.Count); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.AreEqual(0, collection.Count); }
public void SetItemUsesDispatcherToSetItems() { var initialElement = new Element(); var collection = new BindableCollection <Element>() { initialElement }; var element = new Element(); var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection[0] = element; Assert.AreEqual(initialElement, collection[0]); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.AreEqual(element, collection[0]); }
public void ClearItemsUsesDispatcherToRaiseEvents() { var collection = new BindableCollection<Element>() { new Element() }; bool propertyChangedRaised = false; ((INotifyPropertyChanged)collection).PropertyChanged += (o, e) => propertyChangedRaised = true; bool collectionChangingRaised = false; collection.CollectionChanging += (o, e) => collectionChangingRaised = true; bool collectionChangedRaised = false; collection.CollectionChanged += (o, e) => collectionChangedRaised = true; var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.Clear(); Assert.False(propertyChangedRaised); Assert.False(collectionChangingRaised); Assert.False(collectionChangedRaised); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.True(propertyChangedRaised); Assert.True(collectionChangingRaised); Assert.True(collectionChangedRaised); }
public void ClearItemsUsesDispatcherToClearItems() { var collection = new BindableCollection<Element>() { new Element() }; var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.Clear(); Assert.AreEqual(1, collection.Count); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.AreEqual(0, collection.Count); }
public void SetItemUsesDispatcherToSetItems() { var initialElement = new Element(); var collection = new BindableCollection<Element>() { initialElement }; var element = new Element(); var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection[0] = element; Assert.AreEqual(initialElement, collection[0]); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.AreEqual(element, collection[0]); }
public void InsertItemUsesDispatcherToInsertItem() { var collection = new BindableCollection<Element>(); var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.Add(new Element()); Assert.AreEqual(0, collection.Count); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.AreEqual(1, collection.Count); }