internal void UndoAll() { while (m_doneStack.Count > 0) { Assert.AreEqual(m_doneStack.Peek().Undo, m_actionHandler.GetUndoText()); m_actionHandler.Undo(); // put it back on the taskQueue as something that can be Redone. m_taskQueue.Enqueue(m_doneStack.Pop()); } Assert.AreEqual(OriginalUndoCount, m_actionHandler.UndoableSequenceCount); }
/// ------------------------------------------------------------------------------------ /// <summary> /// End the undoable UOW and Undo everything. /// </summary> /// ------------------------------------------------------------------------------------ protected void UndoAll() { IActionHandler actionHandler = Cache.ActionHandlerAccessor; // This ends a UOW, but with no Commit. if (actionHandler.CurrentDepth > 0) { actionHandler.EndUndoTask(); } // Undo the UOW (or more than one of them, if the test made new ones). while (actionHandler.CanUndo()) { actionHandler.Undo(); } // Need to 'Commit' to clear out redo stack, // since nothing is really saved. actionHandler.Commit(); }
/// <summary> /// Two changes have been made, first on firstStack, then on secondStack. Verify that they must be Undone /// in the reverse order, and redone in the same order. /// </summary> /// <param name="firstStack"></param> /// <param name="secondStack"></param> private void VerifyOrderRequired(IActionHandler firstStack, IActionHandler secondStack) { Assert.That(firstStack.CanUndo(), Is.False); // can't undo the first change before the other. Assert.That(secondStack.CanUndo(), Is.True); secondStack.Undo(); // get back to where we can Undo creating it. Assert.That(firstStack.CanUndo(), Is.True); // now the second one is undone, we can firstStack.Undo(); // now both are undone. Assert.That(secondStack.CanRedo(), Is.False); // can't redo the second change first Assert.That(firstStack.CanRedo(), Is.True); // but of course we can redo the first one first firstStack.Redo(); Assert.That(secondStack.CanRedo(), Is.True); // now we can redo the second change, since we already redid the first. }