public void ChangeTrackingAnInpc_WhenNestedPropertyChangedAndUndoRequested_UndoExecutesAndEventsAreRaised()
        {
            InpcAndChangeTrackingEnabled sut = new InpcAndChangeTrackingEnabled();

            sut.PropertyChanged += UniversalPropertyChangedHandler;

            ObjectTracker.Track(sut);

            var nested = new InpcAndChangeTrackingNested();

            nested.PropertyChanged += this.UniversalPropertyChangedHandler;

            sut.Nested = nested;

            var restorePoint = ObjectTracker.SetRestorePoint(sut);

            sut.StringProperty = "string";
            sut.IntProperty    = 1;

            nested.FirstName = "first";
            nested.LastName  = "last";

            ObjectTracker.UndoTo(sut, restorePoint);

            Assert.AreEqual(null, sut.StringProperty);
            Assert.AreEqual(0, sut.IntProperty);
            Assert.AreEqual(" ", sut.Nested.Name);

            Assert.AreEqual(2, this.GetEventCount(sut, s => s.StringProperty));
            Assert.AreEqual(2, this.GetEventCount(sut, s => s.IntProperty));
            Assert.AreEqual(5, this.GetEventCount(sut, s => s.NestedName));
            Assert.AreEqual(5, this.GetEventCount(sut, s => s.NestedIndirectName));
            Assert.AreEqual(2, this.GetEventCount(nested, s => s.FirstName));
            Assert.AreEqual(2, this.GetEventCount(nested, s => s.LastName));
        }
        public void ChangeTrackingAnInpc_WhenNestedPropertyChangedAndUndoRequested_UndoExecutesAndEventsAreRaised()
        {
            InpcAndChangeTrackingEnabled sut = new InpcAndChangeTrackingEnabled();

            sut.PropertyChanged += UniversalPropertyChangedHandler;

            ObjectTracker.Track(sut);

            var nested = new InpcAndChangeTrackingNested();

            nested.PropertyChanged += this.UniversalPropertyChangedHandler;

            sut.Nested = nested;

            var restorePoint = ObjectTracker.SetRestorePoint(sut);

            sut.StringProperty = "string";
            sut.IntProperty = 1;

            nested.FirstName = "first";
            nested.LastName = "last";

            ObjectTracker.UndoTo(sut, restorePoint);

            Assert.AreEqual(null, sut.StringProperty);
            Assert.AreEqual(0, sut.IntProperty);
            Assert.AreEqual(" ", sut.Nested.Name);

            Assert.AreEqual(2, this.GetEventCount(sut, s => s.StringProperty ));
            Assert.AreEqual(2, this.GetEventCount(sut, s => s.IntProperty ));
            Assert.AreEqual(5, this.GetEventCount(sut, s => s.NestedName ));
            Assert.AreEqual(5, this.GetEventCount(sut, s => s.NestedIndirectName ));
            Assert.AreEqual(2, this.GetEventCount(nested, s => s.FirstName ));
            Assert.AreEqual(2, this.GetEventCount(nested, s => s.LastName ));
        }