public void CanUndoCanRedoChangedTest() { _undoServiceForInt.CanRedoChanged += _undoServiceForInt_CanRedoChanged; _undoServiceForInt.CanUndoChanged += _undoServiceForInt_CanUndoChanged; _statefulInt = 1; _undoServiceForInt.RecordState(); Assert.IsTrue(_canUndoChangedFiredCount == 1); //Item added to empty undo stack _canUndoChangedFiredCount = 0; _undoServiceForInt.Undo(); Assert.IsTrue(_canUndoChangedFiredCount == 1); //Last item removed from undo stack _canUndoChangedFiredCount = 0; Assert.IsTrue(_canRedoChangedFiredCount == 1); //Item added to empty redo stack _canRedoChangedFiredCount = 0; _undoServiceForInt.Reset(); Assert.IsTrue(_canRedoChangedFiredCount == 1); //Redo stack cleared _canRedoChangedFiredCount = 0; Assert.IsTrue(_canUndoChangedFiredCount == 0); //Undo Stack was already empty so there was no change _statefulInt = 1; _undoServiceForInt.RecordState(); _undoServiceForInt.Undo(); _canUndoChangedFiredCount = 0; _canRedoChangedFiredCount = 0; _undoServiceForInt.Redo(); Assert.IsTrue(_canRedoChangedFiredCount == 1); //Last item removed from redo stack. _canRedoChangedFiredCount = 0; Assert.IsTrue(_canUndoChangedFiredCount == 1); //Item added to empty undo stack (via undo operation). }
/// <summary> /// Close a project /// </summary> public void CloseProject() { var description = _projectManager.Saved ? "Are you sure?" : "Unsaved changes! Are you sure?"; dialog.Show( "Close Project", description, () => { // Reset the undo redo queue _undoService.Reset(); // Remove the last opened project _configManager.Config.lastProject = ""; _configManager.SaveConfig(); _projectManager.Saved = true; // Reset camera mainController.ResetCamera(); // Remove GameObject of current project componentHighlighting.ResetHighlighting(); searchController.Reset(); Destroy(_projectManager.CurrentProject.ObjectModel); // Show the start screen stationController.CloseStation(); mainScreen.SetActive(false); startScreen.SetActive(true); } ); }