public void LargeOperationTest() { AggregateTrackedObject root = new AggregateTrackedObject(); root.DependentTrackedObject = new SimpleTrackedObject(); var to = (ITrackedObject)root; using (ObjectTracker.StartAtomicOperation(to, "name")) { root.ChangeValuesWithDependent(1, 2, 3); root.ChangeValues(3, 4, 5); root.DependentTrackedObject.ChangeValues(6, 7, 8); } to.Tracker.Undo(); Assert.AreEqual(0, root.P1); Assert.AreEqual(0, root.P2); Assert.AreEqual(0, root.P3); Assert.AreEqual(0, root.DependentTrackedObject.P1); Assert.AreEqual(0, root.DependentTrackedObject.P2); Assert.AreEqual(0, root.DependentTrackedObject.P3); }
public void SimpleAggregateTrackerTest() { AggregateTrackedObject root = new AggregateTrackedObject(); root.DependentTrackedObject = new SimpleTrackedObject(); var to = (ITrackedObject)root; root.ChangeValues(1, 2, 3); to.Tracker.Undo(); Assert.AreEqual(0, root.P1); Assert.AreEqual(0, root.P2); Assert.AreEqual(0, root.P3); root.DependentTrackedObject.ChangeValues(1, 2, 3); to.Tracker.Undo(); Assert.AreEqual(0, root.P1); Assert.AreEqual(0, root.P2); Assert.AreEqual(0, root.P3); Assert.AreEqual(0, root.DependentTrackedObject.P1); Assert.AreEqual(0, root.DependentTrackedObject.P2); Assert.AreEqual(0, root.DependentTrackedObject.P3); }
public void ReattachDependentObject_IfObjectIsUnchanged_RestoresAggregateTracker() { AggregateTrackedObject root = new AggregateTrackedObject(); var dependentObject = new SimpleTrackedObject(); root.DependentTrackedObject = dependentObject; dependentObject.ChangeValues(1, 2, 3); root.DependentTrackedObject = null; dependentObject.ChangeValues(4, 5, 6); ((ITrackedObject)dependentObject).Tracker.Undo(); ((ITrackedObject)root).Tracker.Undo(); ((ITrackedObject)root).Tracker.Undo(); Assert.AreEqual(0, root.DependentTrackedObject.P1); Assert.AreEqual(0, root.DependentTrackedObject.P2); Assert.AreEqual(0, root.DependentTrackedObject.P3); }
public void AggregateMethodChangingDependentTest() { AggregateTrackedObject root = new AggregateTrackedObject(); root.DependentTrackedObject = new SimpleTrackedObject(); var to = (ITrackedObject)root; root.ChangeValuesWithDependent(1, 2, 3); to.Tracker.Undo(); Assert.AreEqual(0, root.P1); Assert.AreEqual(0, root.P2); Assert.AreEqual(0, root.P3); Assert.AreEqual(0, root.DependentTrackedObject.P1); Assert.AreEqual(0, root.DependentTrackedObject.P2); Assert.AreEqual(0, root.DependentTrackedObject.P3); }