public void When_changing_a_scalar_property_then_redo_should_not_work() { //// Arrange var obj = new MockObservableObject(); obj.Name = "A"; var undoRedoManager = new UndoRedoManager(obj, new MockDispatcher()); Assert.IsFalse(undoRedoManager.CanRedo); Assert.IsFalse(undoRedoManager.CanUndo); //// Act obj.Name = "B"; undoRedoManager.Undo(); Assert.IsTrue(undoRedoManager.CanRedo); obj.Name = "C"; //// Assert Assert.IsFalse(undoRedoManager.CanRedo); }
/// <summary>Initializes the document. </summary> /// <param name="data">The JSON data. </param> /// <param name="dispatcher">The UI dispatcher. </param> public void Initialize(JsonObjectModel data, IDispatcher dispatcher) { UndoRedoManager = new UndoRedoManager(data, dispatcher); Data = data; }
public void When_adding_object_to_list_then_undo_should_work() { //// Arrange var obj = new MockObservableObject(); obj.List.Add(new MockObservableObject()); var undoRedoManager = new UndoRedoManager(obj, new MockDispatcher()); Assert.IsFalse(undoRedoManager.CanUndo); Assert.AreEqual(1, obj.List.Count); //// Act obj.List.Add(new MockObservableObject()); Assert.AreEqual(2, obj.List.Count); Assert.IsTrue(undoRedoManager.CanUndo); undoRedoManager.Undo(); //// Assert Assert.AreEqual(1, obj.List.Count); }
public void When_changing_property_of_excluded_child_type_then_undo_should_not_work() { //// Arrange var obj = new MockObservableObject(); obj.AddExcludedChildType(typeof(ObservableObject)); obj.Child = new MockObservableObject { Name = "A" }; var undoRedoManager = new UndoRedoManager(obj, new MockDispatcher()); Assert.IsFalse(undoRedoManager.CanUndo); //// Act obj.Child.Name = "B"; Assert.AreEqual("B", obj.Child.Name); //// Assert Assert.IsFalse(undoRedoManager.CanUndo); }