public void ShouldReportChangeWhenExistingChildrenChange() { var collection = new ObservableCollection<Sample> { new Sample(), new Sample(), new Sample() }; var monitor = new ObservableCollectionMonitor<Sample>(collection, (c, item) => WireEvent(item, true), (c, item) => WireEvent(item, false)); collection[1].Text = "Value"; args.PropertyName.ShouldBe(Sample.PropText); args.Source.ShouldBe(collection[1]); }
public void ShouldReportChangeWhenAddedChildrenChange() { var collection = new ObservableCollection<Sample>(); var monitor = new ObservableCollectionMonitor<Sample>(collection, (c, item) => WireEvent(item, true), (c, item) => WireEvent(item, false)); var child = new Sample(); collection.Add(child); child.Text = "Value"; args.PropertyName.ShouldBe(Sample.PropText); args.Source.ShouldBe(child); }
public void ShouldExposeSourceCollection() { var collection = new ObservableCollection<Sample>(); var monitor = new ObservableCollectionMonitor<Sample>(collection, (c, item) => WireEvent(item, true), (c, item) => WireEvent(item, false)); monitor.Collection.ShouldBe(collection); }
public void ShouldThrowWhenClearCalled() { var collection = new ObservableCollection<Sample>(); var monitor = new ObservableCollectionMonitor<Sample>(collection, (c, item) => WireEvent(item, true), (c, item) => WireEvent(item, false)); Should.Throw<NotSupportedException>(collection.Clear); }
public void ShouldStopReportingChangesWhenRemovedByReplaceOperationInCollection() { var collection = new ObservableCollection<Sample> { new Sample(), new Sample(), new Sample() }; var monitor = new ObservableCollectionMonitor<Sample>(collection, (c, item) => WireEvent(item, true), (c, item) => WireEvent(item, false)); 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 ShouldStopReportingChangesWhenRemovedFromCollection() { var collection = new ObservableCollection<Sample> { new Sample(), new Sample(), new Sample() }; var monitor = new ObservableCollectionMonitor<Sample>(collection, (c, item) => WireEvent(item, true), (c, item) => WireEvent(item, false)); var child = collection[0]; collection.Remove(child); child.Text = "Value"; args.ShouldBe(null); }