public void EnsureSaveDialogIsShownOnOpenIfSaveCommand() { //workspace has unsaved changes this.GetModel().CurrentWorkspace.HasUnsavedChanges = true; //openPath string openPath = Path.Combine(TestDirectory, (@"UI\GroupTest.dyn")); var eventCount = 0; var handler = new WorkspaceSaveEventHandler((o, e) => { eventCount = eventCount + 1; }); //attach handler to the save request ViewModel.RequestUserSaveWorkflow += handler; //send the command ViewModel.OpenIfSavedCommand.Execute(new Dynamo.Models.DynamoModel.OpenFileCommand(openPath)); //dispose handler ViewModel.RequestUserSaveWorkflow -= handler; //assert the request was made Assert.AreEqual(1, eventCount); //assert the filePath was upated correctly //use reflection to get a private field: //TODO(mk) write a better test without reflection or internal which does not raise save dialog in test mode. var filePath = ViewModel.GetType().GetField("filePath", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(ViewModel); Assert.AreEqual(openPath, filePath); }
public void EnsureSaveDialogIsShownOnOpenIfSaveCommand() { //workspace has unsaved changes this.GetModel().CurrentWorkspace.HasUnsavedChanges = true; //openPath string openPath = Path.Combine(TestDirectory, (@"UI\GroupTest.dyn")); var eventCount = 0; var handler = new WorkspaceSaveEventHandler((o, e) => { eventCount = eventCount + 1; }); //attach handler to the save request ViewModel.RequestUserSaveWorkflow += handler; //send the command ViewModel.OpenIfSavedCommand.Execute(new Dynamo.Models.DynamoModel.OpenFileCommand(openPath)); //assert the request was made Assert.AreEqual(1, eventCount); //dispose handler ViewModel.RequestUserSaveWorkflow -= handler; }
public void EnsureSaveDialogIsShownOnOpenIfSaveCommand() { //workspace has unsaved changes this.GetModel().CurrentWorkspace.HasUnsavedChanges = true; //openPath string openPath = Path.Combine(TestDirectory, (@"UI\GroupTest.dyn")); var eventCount = 0; var handler = new WorkspaceSaveEventHandler((o,e) => { eventCount = eventCount + 1; }); //attach handler to the save request ViewModel.RequestUserSaveWorkflow += handler; //send the command ViewModel.OpenIfSavedCommand.Execute(new Dynamo.Models.DynamoModel.OpenFileCommand(openPath)); //assert the request was made Assert.AreEqual(1,eventCount); //dispose handler ViewModel.RequestUserSaveWorkflow -= handler; }