Ejemplo n.º 1
0
        public void Undo_MultipleActions_UndoesActionsInReverseOrder()
        {
            var action = new UndoActionSequence <IUndoAction>(NewAction("a"), NewAction("b"), NewAction("c"));

            Assert.IsTrue(action.Undo());
            Assert.AreEqual(3, m_actionsTaken.Count);
            int i = 0;

            Assert.AreEqual("Undo c", m_actionsTaken[i++]);
            Assert.AreEqual("Undo b", m_actionsTaken[i++]);
            Assert.AreEqual("Undo a", m_actionsTaken[i++]);
        }
Ejemplo n.º 2
0
        public void Undo_OneActionCannotBeUndone_RedoesActionsThatWereUndoneToGetBackToStateBeforeCallingUndo()
        {
            var action = new UndoActionSequence <IUndoAction>(NewAction("a", false), NewAction("b"), NewAction("c"));

            Assert.IsFalse(action.Undo());
            Assert.AreEqual(5, m_actionsTaken.Count);
            int i = 0;

            Assert.AreEqual("Undo c", m_actionsTaken[i++]);
            Assert.AreEqual("Undo b", m_actionsTaken[i++]);
            Assert.AreEqual("Failed to undo a", m_actionsTaken[i++]);
            Assert.AreEqual("Redo b", m_actionsTaken[i++]);
            Assert.AreEqual("Redo c", m_actionsTaken[i++]);
        }