コード例 #1
0
        public void SimpleUndoRedoWithAttributesTest()
        {
            TrackedObject to = new TrackedObject();
            var sot = (ITrackedObject)to;

            to.ChangeValuesTracked(1, 2, 3);

            sot.Tracker.Undo();
            sot.Tracker.Undo();

            Assert.AreEqual(0, to.P1);
            Assert.AreEqual(0, to.P2);
            Assert.AreEqual(0, to.P3);

            sot.Tracker.Redo();
            sot.Tracker.Redo();

            Assert.AreEqual(1, to.P1);
            Assert.AreEqual(2, to.P2);
            Assert.AreEqual(3, to.P3);

            to.ChangeValuesNotTracked(0, 0, 0);
            to.ChangeValuesNotTracked(1, 2, 3);

            sot.Tracker.Undo();

            Assert.AreEqual(1, to.P1);
            Assert.AreEqual(2, to.P2);
            Assert.AreEqual(0, to.P3);

            sot.Tracker.Redo();

            Assert.AreEqual(1, to.P1);
            Assert.AreEqual(2, to.P2);
            Assert.AreEqual(3, to.P3);
        }