public void TestStateChanged() { var provider = new UndoRedoProvider4Test(); var counter = 0; provider.StateChanged += (sender, e) => counter++; Assert.AreEqual(0, counter); provider.AddUndoActionExposed(string.Empty, () => { }, () => { }); Assert.AreEqual(1, counter); provider.Undo(); Assert.AreEqual(2, counter); provider.Redo(); Assert.AreEqual(3, counter); using (provider.BeginMultiActionsUndoRedoStep(string.Empty)) { provider.AddUndoActionExposed(string.Empty, () => { }, () => { }); Assert.AreEqual(3, counter); provider.AddUndoActionExposed(string.Empty, () => { }, () => { }); Assert.AreEqual(3, counter); } Assert.AreEqual(4, counter); using (provider.SuppressUndoRegistration()) { provider.AddUndoActionExposed(string.Empty, () => { }, () => { }); } Assert.AreEqual(4, counter); provider.ClearCache(); Assert.AreEqual(5, counter); }
public void TestSuppressUndoRedo() { var provider = new UndoRedoProvider4Test(); provider.AddUndoActionExposed("Aaa", () => { }, () => { }); Assert.AreEqual("Aaa", provider.UndoDescription); using (provider.SuppressUndoRegistration()) { provider.AddUndoActionExposed("Bbb", () => { }, () => { }); Assert.AreEqual("Aaa", provider.UndoDescription); } provider.AddUndoActionExposed("Bbb", () => { }, () => { }); Assert.AreEqual("Bbb", provider.UndoDescription); }