示例#1
0
        public void removeall_should_raise_propertychanged()
        {
            bool eventWasRaisedForCount   = false;
            bool eventWasRaisedForIsEmpty = false;

            var observableSet = new ObservableSet <int> {
                1, 2, 3, 4
            };

            observableSet.PropertyChanged += (sender, args) =>
            {
                sender.Should().Be.EqualTo(observableSet);
                if (args.PropertyName == ISEMPTY_PROPERTY_NAME)
                {
                    eventWasRaisedForIsEmpty = true;
                }
                if (args.PropertyName == COUNT_PROPERTY_NAME)
                {
                    eventWasRaisedForCount = true;
                }
            };

            observableSet.RemoveAll(new[] { 2, 3 });
            eventWasRaisedForIsEmpty.Should().Be.True();
            eventWasRaisedForCount.Should().Be.True();
        }
示例#2
0
        public void removeall_should_work()
        {
            var observableSet = new ObservableSet <int> {
                1, 2, 3, 4, 5
            };

            observableSet.RemoveAll(new[] { 2, 3 });
            observableSet.Count.Should().Be.EqualTo(3);
            observableSet.Should().Have.SameSequenceAs(new[] { 1, 4, 5 });
        }
示例#3
0
        public void removeall_should_raise_collectionchanged_for_removeditems()
        {
            bool eventWasRaised = false;

            var observableSet = new ObservableSet <int> {
                1, 2, 3, 4
            };

            observableSet.CollectionChanged += (sender, args) =>
            {
                sender.Should().Be.EqualTo(observableSet);
                args.Action.Should().Be.EqualTo(NotifyCollectionChangedAction.Remove);

                args.OldItems.OfType <int>().Should().Have.SameSequenceAs(new[] { 2, 3 });

                args.OldItems.Count.Should().Be.EqualTo(2);

                eventWasRaised = true;
            };

            observableSet.RemoveAll(new[] { 2, 3 });
            eventWasRaised.Should().Be.True();
        }