public void MatrixHistory_Matrix_EqualsToItself() { var matrix1 = new Matrix(new List <List <long> > { new List <long> { 0, 3, 0 }, new List <long> { 0, 2, 0 }, new List <long> { 0, 1, 0 } }); var matrixCheck = new Matrix(new List <List <long> > { new List <long> { 0, 3, 0 }, new List <long> { 0, 2, 0 }, new List <long> { 0, 1, 0 } }); var history = new MatrixHistory(matrix1); history.Backup(); history.Matrix[0, 0] = 1; history.Backup(); history.Matrix[0, 0] = 2; history.Undo(); history.Undo(); Assert.AreEqual(history.Matrix, matrixCheck); }
public bool Undo() { // Try to undo bool success = history.Undo(); // If undo succeeds then update the matrix if (success) { MatrixParent.CurrentMatrix = history.Current.Matrix; MatrixParent.IncreaseMovesMade(); OnHistoryUpdate(); AttemptUndoPreview(); } return(success); }
/// <summary> /// Undoes operations to last backup. /// </summary> public virtual void Undo() { _history.Undo(); }