コード例 #1
0
ファイル: WorkspaceSaving.cs プロジェクト: esalari/Dynamo
        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);
        }
コード例 #2
0
ファイル: WorkspaceSaving.cs プロジェクト: yaoclee/Dynamo
        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;
        }
コード例 #3
0
ファイル: WorkspaceSaving.cs プロジェクト: sm6srw/Dynamo
        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;

        }