Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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 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 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);
        }