Пример #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);
        }
Пример #2
0
        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);
        }
        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);
        }
        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);
        }