示例#1
0
 public void Cleanup()
 {
     AssertNoEventsRaised(() =>
     {
         observableListView.Dispose();
         originalList.Add("disposed");
     });
 }
示例#2
0
        public void RaiseEventsWithoutListener()
        {
            var originalList2       = new ObservableCollection <string>();
            var observableListView2 = new ObservableListViewCore <string>(originalList);

            originalList2.Add("first");
            originalList2.Add("second");
            originalList2.Move(0, 1);
            originalList2.Remove("first");
            originalList2.Add("third");
            originalList2.Clear();

            observableListView2.Dispose();
            observableListView2.Dispose();
        }
示例#3
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 ObservableListViewCore <string>(originalList, StringComparer.OrdinalIgnoreCase);

            listView.Filter = filter;
            listView.Sort   = sort;
            AssertHelper.SequenceEqual(new[] { "A", "b", "D" }, listView);
            listView.Dispose();

            listView = new ObservableListViewCore <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();

            listView = new ObservableListViewCore <string>(originalList, StringComparer.OrdinalIgnoreCase, filter, sort, true);
            AssertHelper.SequenceEqual(new[] { "A", "b", "D" }, listView);
            Assert.AreSame(filter, listView.Filter);
            Assert.AreSame(sort, listView.Sort);

            bool collectionChangedCalled = false;

            listView.CollectionChanged += (sender, e) =>
            {
                collectionChangedCalled = true;
            };
            originalList.Add("e");
            Assert.IsFalse(collectionChangedCalled);
            listView.Dispose();

            AssertHelper.ExpectedException <ArgumentNullException>(() => new ObservableListViewCore <string>(null !));
        }