public void UndoRedoTest() { _objectBeingTracked.Id = 2; _undoService.RecordState(); _objectBeingTracked.Id = 3; _undoService.RecordState(); _undoService.Undo(); _objectBeingTracked.MutableMember.Text = "Changed"; _undoService.RecordState(); _undoService.Undo(); Assert.IsTrue(_objectBeingTracked.Id == 2 && _objectBeingTracked.MutableMember.Text.Equals("Original")); }
public void NoEventHandlerTest() { _statefulInt = 1; _individualUndoService.RecordState(); _statefulInt = 2; _individualUndoService.RecordState(); _individualUndoService.Undo(); Assert.IsTrue(_statefulInt == 1); _individualUndoService.Redo(); Assert.IsTrue(_statefulInt == 2); }
public void AggregateUndoServiceUndoRedoTest() { // UndoServiceAggregate is created using an IUndoService array: var undoServiceForInt = new UndoService <int>(GetIntState, SetIntState, null); var undoServiceForString = new UndoService <string>(GetStringState, SetStringState, null); IUndoService[] subservices = { undoServiceForInt, undoServiceForString }; var serviceAggregate = new UndoServiceAggregate(subservices); // Changes are recorded by the individual UndoServices _statefulInt = 1; undoServiceForInt.RecordState(); _statefulString = "One"; undoServiceForString.RecordState(); _statefulInt = 2; undoServiceForInt.RecordState(); _statefulInt = 3; undoServiceForInt.RecordState(); _statefulString = "Two"; undoServiceForString.RecordState(); /* * The UndoServiceAggregate provides a unified interface for performing undo/redo on the different tracked objects. * (You can also perform Undo/Redo on the individual services, which will undo the last change on the corresponding object.) */ serviceAggregate.Undo(); Assert.IsTrue(_statefulString.Equals("One")); Assert.IsTrue(_statefulInt == 3); serviceAggregate.Undo(); Assert.IsTrue(_statefulString.Equals("One")); Assert.IsTrue(_statefulInt == 2); serviceAggregate.Undo(); Assert.IsTrue(_statefulString.Equals("One")); Assert.IsTrue(_statefulInt == 1); serviceAggregate.Redo(); Assert.IsTrue(_statefulString.Equals("One")); Assert.IsTrue(_statefulInt == 2); serviceAggregate.Redo(); Assert.IsTrue(_statefulString.Equals("One")); Assert.IsTrue(_statefulInt == 3); serviceAggregate.Redo(); Assert.IsTrue(_statefulString.Equals("Two")); Assert.IsTrue(_statefulInt == 3); }
public void UndoRedoTest() { var undoServiceForString = new UndoService <string>(GetStringState, SetStringState, null); _statefulString = "One"; undoServiceForString.RecordState(); _statefulString = "Two"; undoServiceForString.RecordState(); undoServiceForString.Undo(); Assert.IsTrue(_statefulString.Equals("One")); undoServiceForString.Redo(); Assert.IsTrue(_statefulString.Equals("Two")); }
public void IsChangedTest() { var trackedObject = new StatefulClass { TheString = "One", TheInt = 1 }; var undoService = new UndoService <StatefulClassDto>(trackedObject.GetData, trackedObject.SetData, null); Assert.IsTrue(!undoService.IsStateChanged); trackedObject.TheString = "Two"; undoService.RecordState(); Assert.IsTrue(undoService.IsStateChanged); undoService.Undo(); Assert.IsTrue(!undoService.IsStateChanged); undoService.Redo(); Assert.IsTrue(undoService.IsStateChanged); undoService.ClearIsStateChangedFlag(); Assert.IsTrue(!undoService.IsStateChanged); undoService.Undo(); Assert.IsTrue(undoService.IsStateChanged); undoService.Redo(); Assert.IsTrue(!undoService.IsStateChanged); }
public void UndoRedoTest() { _statefulInt = 1; _undoServiceForInt.RecordState(); _statefulInt = 2; _undoServiceForInt.RecordState(); _undoServiceForInt.Undo(); Assert.IsTrue(_statefulInt == 1); _undoServiceForInt.Redo(); Assert.IsTrue(_statefulInt == 2); }