コード例 #1
0
        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;
        }
コード例 #2
0
 public void Shutdown()
 {
     // Set the views to null so that the garbage collector can collect them.
     contactLayoutViewModel.ContactListView = null;
     contactLayoutViewModel.ContactView     = null;
     contactsView?.Dispose();
 }
コード例 #3
0
 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();
 }
コード例 #4
0
 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();
 }
コード例 #5
0
 protected override void OnCleanup()
 {
     AssertNoEventsRaised(() =>
     {
         observableListView.Dispose();
         originalList.Add("disposed");
     });
     base.OnCleanup();
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        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 !));
        }
コード例 #8
0
 public void Shutdown()
 {
     PropertyChangedEventManager.RemoveHandler(ContactListViewModel, ContactListViewModelPropertyChanged, "");
     contactsView.Dispose();
 }
コード例 #9
0
 public void Shutdown()
 {
     contactListViewModelPropertyChangedProxy.Remove();
     contactsView.Dispose();
 }