Beispiel #1
0
        public void addall_should_raise_collectionchanged_for_addeditems()
        {
            var       valuesToAdd       = new[] { 1, 2, 3 };
            const int valueAlreadyAdded = 1;
            bool      eventWasRaised    = false;

            var observableSet = new ObservableSet <int> {
                valueAlreadyAdded
            };

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

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

                args.NewItems.Contains(valueAlreadyAdded).Should().Be.False();

                eventWasRaised = true;
            };

            observableSet.AddAll(valuesToAdd);
            eventWasRaised.Should().Be.True();
        }
Beispiel #2
0
        public void addall_should_raise_propertychanged()
        {
            var  valuesToAdd              = new[] { 1, 2, 3 };
            bool eventWasRaisedForCount   = false;
            bool eventWasRaisedForIsEmpty = false;

            var observableSet = new ObservableSet <int>();

            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.AddAll(valuesToAdd);
            eventWasRaisedForIsEmpty.Should().Be.True();
            eventWasRaisedForCount.Should().Be.True();
        }
Beispiel #3
0
        public void addall_should_work()
        {
            var observableSet = new ObservableSet <int>();

            observableSet.AddAll(new[] { 1, 2, 3 });
            observableSet.Count.Should().Be.EqualTo(3);
            observableSet.Should().Have.SameSequenceAs(new[] { 1, 2, 3 });
        }