public void ReturnsFalseForBatchWithMultipleActions() { var model1 = new Mocks.MockModel(); var model2 = new Mocks.MockModel(); var batch = new Batch(); batch.AddAction(new PropertyChangeUndo(model1, "Value", model1.Value)); batch.AddAction(new PropertyChangeUndo(model2, "Value", model2.Value)); Assert.IsFalse(batch.IsEmptyBatch); }
/// <summary> /// Adds a new undo operation to the stack. /// </summary> /// <param name="operation">The operation.</param> /// <param name="noInsertIfExecutingOperation">Do not insert record if currently running undo/redo.</param> /// <returns><c>true</c> if undo operation was added to stack; otherwise <c>false</c>.</returns> /// <exception cref="ArgumentNullException">The <paramref name="operation"/> is <c>null</c>.</exception> public bool Add(IMementoSupport operation, bool noInsertIfExecutingOperation = true) { Argument.IsNotNull("operation", operation); if (!IsEnabled) { return(false); } if (noInsertIfExecutingOperation && _isUndoingOperation) { return(false); } lock (_lock) { if (_currentBatch != null) { _currentBatch.AddAction(operation); } else { var batch = new Batch(); batch.AddAction(operation); Add(batch); } } return(true); }
public void ReturnsFalseForBatchWithOneAction() { var model = new Mocks.MockModel(); var batch = new Batch(); batch.AddAction(new PropertyChangeUndo(model, "Value", model.Value)); Assert.IsFalse(batch.IsEmptyBatch); }
public void ReturnsOneForBatchWithOneAction() { var model = new Mocks.MockModel(); var batch = new Batch(); batch.AddAction(new PropertyChangeUndo(model, "Value", model.Value)); Assert.AreEqual(1, batch.ActionCount); }
public void IsTrueWhenAtLeastOneActionCanRedo() { var model1 = new Mocks.MockModel(); var model2 = new Mocks.MockModel(); var batch = new Batch(); batch.AddAction(new PropertyChangeUndo(model1, "Value", model1.Value)); batch.AddAction(new PropertyChangeUndo(model2, "Value", model2.Value)); Assert.IsTrue(batch.CanRedo); }
public void IsFalseWhenNoActionsCanRedo() { var model1 = new Mocks.MockModel(); var batch = new Batch(); batch.AddAction(new ActionUndo(model1, () => model1.Value = "Value")); Assert.IsFalse(batch.CanRedo); }
/// <summary> /// Adds a new undo operation to the stack. /// </summary> /// <param name="operation">The operation.</param> /// <param name="noInsertIfExecutingOperation">Do not insert record if currently running undo/redo.</param> /// <returns><c>true</c> if undo operation was added to stack; otherwise <c>false</c>.</returns> /// <exception cref="ArgumentNullException">The <paramref name="operation"/> is <c>null</c>.</exception> public bool Add(IMementoSupport operation, bool noInsertIfExecutingOperation = true) { Argument.IsNotNull("operation", operation); if (!IsEnabled) { return false; } if (noInsertIfExecutingOperation && _isUndoingOperation) { return false; } lock (_lock) { if (_currentBatch != null) { _currentBatch.AddAction(operation); } else { var batch = new Batch(); batch.AddAction(operation); Add(batch); } } return true; }