public void retainall_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.RetainAll(new[] { 2, 3 }); eventWasRaisedForIsEmpty.Should().Be.True(); eventWasRaisedForCount.Should().Be.True(); }
public void retainall_should_work() { ObservableSet <int> observableSet = new ObservableSet <int> { 1, 2, 3, 4, 5 }; observableSet.RetainAll(new[] { 2, 3 }); observableSet.Count.Should().Be.EqualTo(2); observableSet.Should().Have.SameSequenceAs(new[] { 2, 3 }); }
public void retainall_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[] { 1, 4 }); args.OldItems.Count.Should().Be.EqualTo(2); eventWasRaised = true; }; observableSet.RetainAll(new[] { 2, 3 }); eventWasRaised.Should().Be.True(); }