public void CollectionChangedTest() { var originalCollection = new ObservableCollection <MyModel>() { new MyModel() }; var listView = new ObservableListView <MyModel>(originalCollection); AssertHelper.SequenceEqual(originalCollection, listView); // Check add operation with collection changed event. bool handlerCalled = false; void Handler(object sender, NotifyCollectionChangedEventArgs e) { handlerCalled = true; Assert.AreEqual(listView, sender); Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action); Assert.AreEqual(1, e.NewStartingIndex); Assert.AreEqual(originalCollection.Last(), e.NewItems.Cast <MyModel>().Single()); } listView.CollectionChanged += Handler; originalCollection.Add(new MyModel()); Assert.IsTrue(handlerCalled); // After dispose the collection does not synchronize anymore handlerCalled = false; listView.Dispose(); originalCollection.Add(new MyModel()); Assert.IsFalse(handlerCalled); listView.CollectionChanged -= Handler; }
public void Shutdown() { // Set the views to null so that the garbage collector can collect them. contactLayoutViewModel.ContactListView = null; contactLayoutViewModel.ContactView = null; contactsView?.Dispose(); }
public void Shutdown() { PropertyChangedEventManager.RemoveHandler(EmailListViewModel, EmailListViewModelPropertyChanged, ""); // Set the views to null so that the garbage collector can collect them. emailLayoutViewModel.EmailListView = null; emailLayoutViewModel.EmailView = null; emailsView.Dispose(); }
public void Shutdown() { emailListViewModelPropertyChangedProxy?.Remove(); // Set the views to null so that the garbage collector can collect them. emailLayoutViewModel.EmailListView = null; emailLayoutViewModel.EmailView = null; emailsView.Dispose(); }
protected override void OnCleanup() { AssertNoEventsRaised(() => { observableListView.Dispose(); originalList.Add("disposed"); }); base.OnCleanup(); }
public void DisposeTest() { var originalCollection = new ObservableCollection <MyModel>(); var filterCalled = false; var listView = new ObservableListView <MyModel>(originalCollection, null, x => { filterCalled = true; return(true); }, null); originalCollection.Add(new MyModel()); Assert.IsTrue(filterCalled); // Calling dispose twice must not throw an exception. listView.Dispose(); listView.Dispose(); filterCalled = false; originalCollection.Add(new MyModel()); Assert.IsFalse(filterCalled); }
public void ConstructorTest() { var originalList = new ObservableCollection <string>(new[] { "D", "A", "c", "b" }); Predicate <string> filter = x => x != "c"; Func <IEnumerable <string>, IOrderedEnumerable <string> > sort = x => x.OrderBy(y => y); var listView = new ObservableListView <string>(originalList, StringComparer.OrdinalIgnoreCase); listView.Filter = filter; listView.Sort = sort; AssertHelper.SequenceEqual(new[] { "A", "b", "D" }, listView); listView.Dispose(); listView = new ObservableListView <string>(originalList, StringComparer.OrdinalIgnoreCase, filter, sort); AssertHelper.SequenceEqual(new[] { "A", "b", "D" }, listView); Assert.AreSame(filter, listView.Filter); Assert.AreSame(sort, listView.Sort); listView.Dispose(); AssertHelper.ExpectedException <ArgumentNullException>(() => new ObservableListView <string>(null !)); }
public void Shutdown() { PropertyChangedEventManager.RemoveHandler(ContactListViewModel, ContactListViewModelPropertyChanged, ""); contactsView.Dispose(); }
public void Shutdown() { contactListViewModelPropertyChangedProxy.Remove(); contactsView.Dispose(); }