public void SequenceOf2Areas() { var area1 = new UndoRedoArea("area1"); var area2 = new UndoRedoArea("area2"); var i1 = new UndoRedo<int>(0); var i2 = new UndoRedo<int>(0); using (area1.Start("command1")) { i1.Value = 1; area1.Commit(); } using (area2.Start("command2")) { i2.Value = 2; area2.Commit(); } Assert.AreEqual(1, i1.Value, "value from area1 is wrong"); Assert.AreEqual(2, i2.Value, "value from area2 is wrong"); area1.Undo(); area2.Undo(); Assert.AreEqual(0, i1.Value, "value from area1 is wrong"); Assert.AreEqual(0, i2.Value, "value from area2 is wrong"); area1.Redo(); area2.Redo(); Assert.AreEqual(1, i1.Value, "value from area1 is wrong"); Assert.AreEqual(2, i2.Value, "value from area2 is wrong"); }
public void WrongUndo() { var area1 = new UndoRedoArea("area1"); var area2 = new UndoRedoArea("area2"); var i = new UndoRedo<int>(0); using (area1.Start("command1")) { i.Value = 1; area1.Commit(); } using (area2.Start("command2")) { area1.Undo(); } }