public void ChangesShouldPropagateThroughMultilevelCollections() { (new TestScheduler()).With(sched => { var input = new ModelTestFixture() { TestString = "Foo" }; var coll = new SerializedCollection <ISerializableItem>(new[] { input }); var fixture = new SerializedCollection <ISerializableList <ISerializableItem> >(new[] { (ISerializableList <ISerializableItem>)coll }); this.Log().DebugFormat("input = {0:X}, coll = {1:X}, fixture = {2:X}", input.GetHashCode(), coll.GetHashCode(), fixture.GetHashCode()); bool inputChanging = false; bool inputChanged = false; bool collChanging = false; bool collChanged = false; bool fixtureChanging = false; bool fixtureChanged = false; input.Changing.Subscribe(_ => inputChanging = true); input.Changed.Subscribe(_ => inputChanged = true); coll.ItemChanging.Subscribe(_ => collChanging = true); coll.ItemChanging.Subscribe(_ => collChanged = true); fixture.ItemChanging.Subscribe(_ => fixtureChanging = true); fixture.ItemChanged.Subscribe(_ => fixtureChanged = true); input.TestString = "Bar"; sched.RunToMilliseconds(1000); this.Log().DebugFormat("inputChanging = {0}", inputChanging); this.Log().DebugFormat("inputChanged = {0}", inputChanged); this.Log().DebugFormat("collChanging = {0}", collChanging); this.Log().DebugFormat("collChanged = {0}", collChanged); this.Log().DebugFormat("fixtureChanging = {0}", fixtureChanging); this.Log().DebugFormat("fixtureChanged = {0}", fixtureChanged); Assert.True(inputChanging); Assert.True(inputChanged); Assert.True(collChanging); Assert.True(collChanged); Assert.True(fixtureChanging); Assert.True(fixtureChanged); }); }
public void ChangesShouldPropagateThroughMultilevelCollections() { (new TestScheduler()).With(sched => { var input = new ModelTestFixture() {TestString = "Foo"}; var coll = new SerializedCollection<ISerializableItem>(new[] {input}); var fixture = new SerializedCollection<ISerializableList<ISerializableItem>>(new[] {(ISerializableList<ISerializableItem>)coll}); this.Log().DebugFormat("input = {0:X}, coll = {1:X}, fixture = {2:X}", input.GetHashCode(), coll.GetHashCode(), fixture.GetHashCode()); bool inputChanging = false; bool inputChanged = false; bool collChanging = false; bool collChanged = false; bool fixtureChanging = false; bool fixtureChanged = false; input.Changing.Subscribe(_ => inputChanging = true); input.Changed.Subscribe(_ => inputChanged = true); coll.ItemChanging.Subscribe(_ => collChanging = true); coll.ItemChanging.Subscribe(_ => collChanged = true); fixture.ItemChanging.Subscribe(_ => fixtureChanging = true); fixture.ItemChanged.Subscribe(_ => fixtureChanged = true); input.TestString = "Bar"; sched.RunToMilliseconds(1000); this.Log().DebugFormat("inputChanging = {0}", inputChanging); this.Log().DebugFormat("inputChanged = {0}", inputChanged); this.Log().DebugFormat("collChanging = {0}", collChanging); this.Log().DebugFormat("collChanged = {0}", collChanged); this.Log().DebugFormat("fixtureChanging = {0}", fixtureChanging); this.Log().DebugFormat("fixtureChanged = {0}", fixtureChanged); Assert.True(inputChanging); Assert.True(inputChanged); Assert.True(collChanging); Assert.True(collChanged); Assert.True(fixtureChanging); Assert.True(fixtureChanged); }); }