public void ShouldReportChangeWhenExistingChildrenChange()
        {
            var collection = new ObservableCollection<Sample> { new Sample(), new Sample(), new Sample() };
            var monitor = new NotifyPropertyChangedCollectionMonitor<Sample>(collection);

            ChildPropertyChangedEventArgs<Sample> args = null;
            monitor.PropertyChanged += (sender, e) => args = e;

            collection[1].Text = "Value";

            args.PropertyName.ShouldBe(Sample.PropText);
            args.Source.ShouldBe(collection[1]);
        }
        public void ShouldStopReportingChangesWhenRemovedFromCollection()
        {
            var collection = new ObservableCollection<Sample> { new Sample(), new Sample(), new Sample() };
            var monitor = new NotifyPropertyChangedCollectionMonitor<Sample>(collection);

            ChildPropertyChangedEventArgs<Sample> args = null;
            monitor.PropertyChanged += (sender, e) => args = e;

            var child = collection[0];
            collection.Remove(child);
            child.Text = "Value";

            args.ShouldBe(null);
        }
        public void ShouldStopReportingChangesWhenRemovedByReplaceOperationInCollection()
        {
            var collection = new ObservableCollection<Sample> { new Sample(), new Sample(), new Sample() };
            var monitor = new NotifyPropertyChangedCollectionMonitor<Sample>(collection);

            ChildPropertyChangedEventArgs<Sample> args = null;
            monitor.PropertyChanged += (sender, e) => args = e;

            var childOld = collection[0];
            var childNew = new Sample();
            collection[0] = childNew;

            childOld.Text = "Value";
            args.ShouldBe(null);

            childNew.Text = "Value";
            args.PropertyName.ShouldBe(Sample.PropText);
            args.Source.ShouldBe(childNew);
        }
 public void ShouldExposeSourceCollection()
 {
     var collection = new ObservableCollection<Sample>();
     var monitor = new NotifyPropertyChangedCollectionMonitor<Sample>(collection);
     monitor.Collection.ShouldBe(collection);
 }
        public void ShouldThrowWhenClearCalled()
        {
            var collection = new ObservableCollection<Sample>();
            var monitor = new NotifyPropertyChangedCollectionMonitor<Sample>(collection);

            Should.Throw<NotSupportedException>(collection.Clear);
        }