public void UndoTo_ActionRemaining() { MockupAction action = new MockupAction(); undoRedoManager.RegisterExecutedAction(action); undoRedoManager.RegisterExecutedAction(action); undoRedoManager.RegisterExecutedAction(action); undoRedoManager.RegisterExecutedAction(action); undoRedoManager.UndoTo(2); Assert.Equal(2, undoRedoManager.History.Count()); Assert.Equal(2, undoRedoManager.HistoryCount); }
public void Undo_MultipleActions_UndoInvoked_CanUndo() { MockupAction action1 = new MockupAction(); MockupAction action2 = new MockupAction(); undoRedoManager.RegisterExecutedAction(action1); undoRedoManager.RegisterExecutedAction(action2); undoRedoManager.UndoAll(); Assert.True(action1.IsUndoInvoked); Assert.True(action2.IsUndoInvoked); Assert.True(undoRedoManager.CanRedo); Assert.False(undoRedoManager.CanUndo); }
public void Redo_SingleAction_RedoInvoked() { EventHandler <StateChangedEventArgs> handler = (sender, e) => { Assert.Equal(StateChangedReason.Redo, e.Reason); }; MockupAction action = new MockupAction(); undoRedoManager.RegisterExecutedAction(action); undoRedoManager.UndoAll(); undoRedoManager.StateChanged += handler; undoRedoManager.Redo(); undoRedoManager.StateChanged -= handler; Assert.True(action.IsRedoInvoked); Assert.True(undoRedoManager.CanUndo); Assert.False(undoRedoManager.CanRedo); }
public void RegisterExecutedAction_WithUndoAction_StartedAfterFirstAction() { MockupAction oldAction1 = new MockupAction(); MockupAction oldAction2 = new MockupAction(); undoRedoManager.RegisterExecutedAction(oldAction1); undoRedoManager.RegisterExecutedAction(oldAction2); undoRedoManager.Undo(); MockupAction action1 = new MockupAction(); MockupAction action2 = new MockupAction(); undoRedoManager.RegisterExecutedAction(action1); Assert.True(undoRedoManager.CanUndo); undoRedoManager.RegisterExecutedAction(action2); Assert.True(undoRedoManager.CanUndo); }
public void RegisterExecutedAction_WithUndoneActions_StartedFromScratch() { MockupAction oldAction1 = new MockupAction(); MockupAction oldAction2 = new MockupAction(); undoRedoManager.RegisterExecutedAction(oldAction1); undoRedoManager.RegisterExecutedAction(oldAction2); undoRedoManager.UndoAll(); MockupAction action1 = new MockupAction(); MockupAction action2 = new MockupAction(); undoRedoManager.RegisterExecutedAction(action1); Assert.True(undoRedoManager.CanUndo); undoRedoManager.RegisterExecutedAction(action2); Assert.True(undoRedoManager.CanUndo); }
public void ManyActions_UndoRedo_ActionsInvoked() { MockupAction action1 = new MockupAction(); MockupAction action2 = new MockupAction(); CompositeUndoRedoAction composite = new CompositeUndoRedoAction("MyName", DateTimeOffset.Now); composite.Add(action1); composite.Add(action2); Assert.Equal(2, composite.Actions.Count); composite.Undo(); Assert.True(action1.IsUndoInvoked); Assert.True(action2.IsUndoInvoked); composite.Redo(); Assert.True(action1.IsRedoInvoked); Assert.True(action2.IsRedoInvoked); }
public void RegisterExecutedAction_CanUndo() { EventHandler <StateChangedEventArgs> handler = (sender, e) => { Assert.Equal(StateChangedReason.Register, e.Reason); }; MockupAction action1 = new MockupAction(); MockupAction action2 = new MockupAction(); undoRedoManager.StateChanged += handler; undoRedoManager.RegisterExecutedAction(action1); undoRedoManager.StateChanged -= handler; Assert.Equal(1, undoRedoManager.History.Count()); Assert.Equal(1, undoRedoManager.HistoryCount); Assert.True(undoRedoManager.CanUndo); undoRedoManager.RegisterExecutedAction(action2); Assert.Equal(2, undoRedoManager.History.Count()); Assert.Equal(2, undoRedoManager.HistoryCount); Assert.True(undoRedoManager.CanUndo); }