public void QuickDebug()
        {
            if (DebugOutputViewModel.IsProcessing)
            {
                StopExecution();
                Thread.Sleep(500);
            }
            if (WorkflowDesignerViewModel.ValidatResourceModel(ContextualResourceModel.DataList))
            {
                var successfuleSave = Save(ContextualResourceModel, true);
                if (!successfuleSave)
                {
                    return;
                }
            }
            else
            {
                _popupController.Show("Please resolve all variable errors, before debugging." + System.Environment.NewLine, "Error Debugging", MessageBoxButton.OK, MessageBoxImage.Error, "true");
                SetDebugStatus(DebugStatus.Finished);
                return;
            }

            SetDebugStatus(DebugStatus.Configure);
            var inputDataViewModel = SetupForDebug(ContextualResourceModel, true);

            inputDataViewModel.LoadWorkflowInputs();
            inputDataViewModel.Save();
        }
Пример #2
0
 void DockManager_OnPaneDragOver(object sender, PaneDragOverEventArgs e)
 {
     if (e.DragAction.GetType() != typeof(MoveWindowAction))
     {
         var           contentPane   = e.Panes[0];
         MainViewModel mainViewModel = DataContext as MainViewModel;
         if (mainViewModel != null && contentPane != null)
         {
             var windows = Application.Current.Windows;
             foreach (var window in windows)
             {
                 var actuallWindow = window as Window;
                 if (actuallWindow != null)
                 {
                     var windowType = actuallWindow.GetType();
                     if (windowType.FullName == "Infragistics.Windows.Controls.ToolWindowHostWindow")
                     {
                         WorkflowDesignerViewModel workflowDesignerViewModel = contentPane.TabHeader as WorkflowDesignerViewModel;
                         if (workflowDesignerViewModel != null && contentPane.ContentVisibility == Visibility.Visible)
                         {
                             PaneDragAction paneDragAction = e.DragAction;
                             if (paneDragAction is AddToGroupAction || paneDragAction is NewSplitPaneAction || paneDragAction is NewTabGroupAction)
                             {
                                 e.IsValidDragAction = false;
                                 e.Cursor            = Cursors.No;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #3
0
        public void QuickDebug()
        {
            if (DebugOutputViewModel.IsProcessing)
            {
                StopExecution();
            }
            if (WorkflowDesignerViewModel.ValidatResourceModel(ContextualResourceModel.DataList))
            {
                if (!ContextualResourceModel.IsWorkflowSaved && !_workspaceSaved)
                {
                    var successfuleSave = Save(ContextualResourceModel, true);
                    if (!successfuleSave)
                    {
                        return;
                    }
                }
            }
            else
            {
                _popupController.Show(StringResources.Debugging_Error,
                                      StringResources.Debugging_Error_Title,
                                      MessageBoxButton.OK, MessageBoxImage.Error, "", false, true, false, false, false, false);

                SetDebugStatus(DebugStatus.Finished);
                return;
            }
            var inputDataViewModel = SetupForDebug(ContextualResourceModel, true);

            inputDataViewModel.LoadWorkflowInputs();
            inputDataViewModel.Save();
        }
Пример #4
0
        public static void AddDesignerAttributes(WorkflowDesignerViewModel workflowVm, bool liteInit = false)
        {
            var designerAttributes = new Dictionary<Type, Type>
            {
                { typeof(DsfMultiAssignActivity), typeof(MultiAssignDesigner) },
                { typeof(DsfDateTimeActivity), typeof(DateTimeDesigner) },
                { typeof(DsfWebGetRequestWithTimeoutActivity), typeof(GetWebRequestWithTimeOutDesigner) },
                { typeof(DsfWebGetRequestActivity), typeof(GetWebRequestDesigner) },
                { typeof(DsfFindRecordsMultipleCriteriaActivity), typeof(FindRecordsMultipleCriteriaDesigner) },
                { typeof(DsfSqlBulkInsertActivity), typeof(SqlBulkInsertDesigner) },
                { typeof(DsfSortRecordsActivity), typeof(SortRecordsDesigner) },
                { typeof(DsfCountRecordsetActivity), typeof(CountRecordsDesigner) },
                { typeof(DsfRecordsetLengthActivity), typeof(RecordsLengthDesigner) },
                { typeof(DsfDeleteRecordActivity), typeof(DeleteRecordsDesigner) },
                { typeof(DsfUniqueActivity), typeof(UniqueRecordsDesigner) },
                { typeof(DsfCalculateActivity), typeof(CalculateDesigner) },
                { typeof(DsfBaseConvertActivity), typeof(BaseConvertDesigner) },
                { typeof(DsfNumberFormatActivity), typeof(FormatNumberDesigner) },
                { typeof(DsfPathCopy), typeof(CopyDesigner) },
                { typeof(DsfPathCreate), typeof(CreateDesigner) },
                { typeof(DsfPathMove), typeof(MoveDesigner) },
                { typeof(DsfPathDelete), typeof(DeleteDesigner) },
                { typeof(DsfFileRead), typeof(ReadFileDesigner) },
                { typeof(DsfFileWrite), typeof(WriteFileDesigner) },
                { typeof(DsfFolderRead), typeof(ReadFolderDesigner) },
                { typeof(DsfPathRename), typeof(RenameDesigner) },
                { typeof(DsfUnZip), typeof(UnzipDesigner) },
                { typeof(DsfZip), typeof(ZipDesigner) },
                { typeof(DsfExecuteCommandLineActivity), typeof(CommandLineDesigner) },
                { typeof(DsfCommentActivity), typeof(CommentDesigner) },
                { typeof(DsfSequenceActivity), typeof(SequenceDesigner) },
                { typeof(DsfDateTimeDifferenceActivity), typeof(DateTimeDifferenceDesigner) },
                { typeof(DsfSendEmailActivity), typeof(EmailDesigner) },
                { typeof(DsfIndexActivity), typeof(FindIndexDesigner) },
                { typeof(DsfRandomActivity), typeof(RandomDesigner) },
                { typeof(DsfReplaceActivity), typeof(ReplaceDesigner) },
                { typeof(DsfScriptingActivity), typeof(ScriptDesigner) },
                { typeof(DsfForEachActivity), typeof(ForeachDesigner) },
                { typeof(DsfCaseConvertActivity), typeof(CaseConvertDesigner) },
                { typeof(DsfDataMergeActivity), typeof(DataMergeDesigner) },
                { typeof(DsfDataSplitActivity), typeof(DataSplitDesigner) },
                { typeof(DsfGatherSystemInformationActivity), typeof(GatherSystemInformationDesigner) },
                { typeof(DsfXPathActivity), typeof(XPathDesigner) },
                { typeof(DsfActivity), typeof(ServiceDesigner) },
                { typeof(DsfDatabaseActivity), typeof(ServiceDesigner) },
                { typeof(DsfWebserviceActivity), typeof(ServiceDesigner) },
                { typeof(DsfPluginActivity), typeof(ServiceDesigner) },
                { typeof(DsfFindRecordsActivity), typeof(DsfFindRecordsActivityDesigner) },
                { typeof(DsfScriptingJavaScriptActivity), typeof(DsfScriptingJavaScriptDesigner) },
                { typeof(DsfDropBoxFileActivity), typeof(DropboxUploadFileDesigner) },
                { typeof(DsfCreateJsonActivity), typeof(CreateJsonDesigner) },
                { typeof(SharepointReadListActivity), typeof(SharepointListReadDesigner) },
                { typeof(SharepointCreateListItemActivity), typeof(SharepointListCreateDesigner) },
                { typeof(SharepointDeleteListItemActivity), typeof(SharepointListDeleteDesigner) },
                { typeof(SharepointUpdateListItemActivity), typeof(SharepointListUpdateDesigner) }
            };

            workflowVm.InitializeDesigner(designerAttributes, liteInit);
        }
Пример #5
0
        public async Task <IViewComponentResult> InvokeAsync(Workflow workflow, CancellationToken cancellationToken)
        {
            var activityShapes = await BuildActivityShapesAsync(workflow, cancellationToken);

            var viewModel = new WorkflowDesignerViewModel(workflow, activityShapes);

            return(View(viewModel));
        }
        public void FindMissing()
        {
            WorkflowDesignerViewModel model = WorkSurfaceViewModel as WorkflowDesignerViewModel;

            if (model != null)
            {
                var vm = model;
                vm.AddMissingWithNoPopUpAndFindUnusedDataListItems();
            }
        }
        public static void AddDesignerAttributes(WorkflowDesignerViewModel workflowVm, bool liteInit = false)
        {
            var designerAttributes = new Dictionary <Type, Type>
            {
                { typeof(DsfMultiAssignActivity), typeof(MultiAssignDesigner) },
                { typeof(DsfDateTimeActivity), typeof(DateTimeDesigner) },
                { typeof(DsfWebGetRequestActivity), typeof(GetWebRequestDesigner) },
                { typeof(DsfFindRecordsMultipleCriteriaActivity), typeof(FindRecordsMultipleCriteriaDesigner) },
                { typeof(DsfSqlBulkInsertActivity), typeof(SqlBulkInsertDesigner) },
                { typeof(DsfSortRecordsActivity), typeof(SortRecordsDesigner) },
                { typeof(DsfCountRecordsetActivity), typeof(CountRecordsDesigner) },
                { typeof(DsfRecordsetLengthActivity), typeof(RecordsLengthDesigner) },
                { typeof(DsfDeleteRecordActivity), typeof(DeleteRecordsDesigner) },
                { typeof(DsfUniqueActivity), typeof(UniqueRecordsDesigner) },
                { typeof(DsfCalculateActivity), typeof(CalculateDesigner) },
                { typeof(DsfBaseConvertActivity), typeof(BaseConvertDesigner) },
                { typeof(DsfNumberFormatActivity), typeof(FormatNumberDesigner) },
                { typeof(DsfPathCopy), typeof(CopyDesigner) },
                { typeof(DsfPathCreate), typeof(CreateDesigner) },
                { typeof(DsfPathMove), typeof(MoveDesigner) },
                { typeof(DsfPathDelete), typeof(DeleteDesigner) },
                { typeof(DsfFileRead), typeof(ReadFileDesigner) },
                { typeof(DsfFileWrite), typeof(WriteFileDesigner) },
                { typeof(DsfFolderRead), typeof(ReadFolderDesigner) },
                { typeof(DsfPathRename), typeof(RenameDesigner) },
                { typeof(DsfUnZip), typeof(UnzipDesigner) },
                { typeof(DsfZip), typeof(ZipDesigner) },
                { typeof(DsfExecuteCommandLineActivity), typeof(CommandLineDesigner) },
                { typeof(DsfCommentActivity), typeof(CommentDesigner) },
                { typeof(DsfSequenceActivity), typeof(SequenceDesigner) },
                { typeof(DsfDateTimeDifferenceActivity), typeof(DateTimeDifferenceDesigner) },
                { typeof(DsfSendEmailActivity), typeof(EmailDesigner) },
                { typeof(DsfIndexActivity), typeof(FindIndexDesigner) },
                { typeof(DsfRandomActivity), typeof(RandomDesigner) },
                { typeof(DsfReplaceActivity), typeof(ReplaceDesigner) },
                { typeof(DsfScriptingActivity), typeof(ScriptDesigner) },
                { typeof(DsfForEachActivity), typeof(ForeachDesigner) },
                { typeof(DsfCaseConvertActivity), typeof(CaseConvertDesigner) },
                { typeof(DsfDataMergeActivity), typeof(DataMergeDesigner) },
                { typeof(DsfDataSplitActivity), typeof(DataSplitDesigner) },
                { typeof(DsfGatherSystemInformationActivity), typeof(GatherSystemInformationDesigner) },
                { typeof(DsfXPathActivity), typeof(XPathDesigner) },
                { typeof(DsfActivity), typeof(ServiceDesigner) },
                { typeof(DsfDatabaseActivity), typeof(ServiceDesigner) },
                { typeof(DsfWebserviceActivity), typeof(ServiceDesigner) },
                { typeof(DsfPluginActivity), typeof(ServiceDesigner) },
                { typeof(DsfWebPageActivity), typeof(DsfWebPageActivityDesigner) },
                { typeof(DsfWebSiteActivity), typeof(DsfWebSiteActivityDesigner) },
                { typeof(DsfFindRecordsActivity), typeof(DsfFindRecordsActivityDesigner) },
                { typeof(DsfScriptingJavaScriptActivity), typeof(DsfScriptingJavaScriptDesigner) },
                // Travis.Frisinger : 25.09.2012 - Removed Http Activity as it is out of sync with the current release 1 plans
            };

            workflowVm.InitializeDesigner(designerAttributes, liteInit);
        }
Пример #8
0
        public static WorkSurfaceContextViewModel CreateResourceViewModel(IContextualResourceModel resourceModel, bool createDesigner = true)
        {
            var key = WorkSurfaceKeyFactory.CreateKey(resourceModel);

            var workSurfaceVm = new WorkflowDesignerViewModel(resourceModel, createDesigner);

            var contextVm = new WorkSurfaceContextViewModel(key, workSurfaceVm)
            {
                DataListViewModel = DataListViewModelFactory.CreateDataListViewModel(resourceModel)
            };

            return(contextVm);
        }
Пример #9
0
        public static WorkSurfaceContextViewModel CreateResourceViewModel(IContextualResourceModel resourceModel, bool createDesigner, IPopupController popupController, IAsyncWorker asyncWorker)
        {
            var key = WorkSurfaceKeyFactory.CreateKey(resourceModel);

            var workSurfaceVm = new WorkflowDesignerViewModel(EventPublishers.Aggregator, resourceModel, new WorkflowHelper(), popupController, asyncWorker, createDesigner);

            var contextVm = new WorkSurfaceContextViewModel(key, workSurfaceVm)
            {
                DataListViewModel = DataListViewModelFactory.CreateDataListViewModel(resourceModel)
            };

            return(contextVm);
        }
Пример #10
0
        void ActuallWindowOnActivated(object sender, EventArgs eventArgs)
        {
            MainViewModel mainViewModel = DataContext as MainViewModel;

            if (mainViewModel != null && _contentPane != null)
            {
                WorkflowDesignerViewModel workflowDesignerViewModel = _contentPane.TabHeader as WorkflowDesignerViewModel;
                if (workflowDesignerViewModel != null && _contentPane.ContentVisibility == Visibility.Visible)
                {
                    mainViewModel.AddWorkSurfaceContext(workflowDesignerViewModel.ResourceModel);
                }
            }
        }
Пример #11
0
        // GET: Workflow
        public ActionResult Designer()
        {
            ViewData["WorkflowDesign"] = "active";

            var viewModel = new WorkflowDesignerViewModel()
            {
                LeaseWorkflowStages   = workflowService.GetWorkflowStages().OrderByDescending(lv => lv.StageOrderNumber),
                InvoiceWorkflowStages = invoiceWorkflowService.GetWorkflowStages().OrderByDescending(lv => lv.StageOrderNumber),
                ChangeWorkflowStages  = changeWorkflowService.GetWorkflowStages().OrderByDescending(lv => lv.StageOrderNumber)
            };

            return(View(viewModel));
        }
Пример #12
0
        public void UpdatePane(ContentPane contentPane)
        {
            if (contentPane == null)
            {
                throw new ArgumentNullException("contentPane");
            }


            WorkflowDesignerViewModel workflowDesignerViewModel = contentPane.TabHeader as WorkflowDesignerViewModel;

            if (workflowDesignerViewModel != null && contentPane.ContentVisibility == Visibility.Visible)
            {
                contentPane.CloseButtonVisibility = Visibility.Visible;
            }
        }
Пример #13
0
        static WorkflowDesignerViewModel CreateWorkflowDesignerViewModel(IEventAggregator eventPublisher, IContextualResourceModel resourceModel, IWorkflowHelper workflowHelper = null, bool createDesigner = true, string helperText = null)
        {
            eventPublisher = eventPublisher ?? new Mock <IEventAggregator>().Object;

            var popupController = new Mock <IPopupController>();

            if (workflowHelper == null)
            {
                var wh = new Mock <IWorkflowHelper>();
                wh.Setup(h => h.CreateWorkflow(It.IsAny <string>())).Returns(() => new ActivityBuilder {
                    Implementation = new DynamicActivity()
                });
                if (helperText != null)
                {
                    wh.Setup(h => h.SanitizeXaml(It.IsAny <StringBuilder>())).Returns(new StringBuilder(helperText));
                }
                workflowHelper = wh.Object;
            }

            var viewModel = new WorkflowDesignerViewModel(eventPublisher, resourceModel, workflowHelper, popupController.Object, new SynchronousAsyncWorker(), createDesigner, true);

            return(viewModel);
        }
Пример #14
0
        public void MainViewModelOnDeactivateWithTrueExpectedSavesResourceModels()
        {
            lock (syncroot)
            {
                var wsiRepo = new Mock<IWorkspaceItemRepository>();
                wsiRepo.Setup(r => r.WorkspaceItems).Returns(() => new List<IWorkspaceItem>());
                wsiRepo.Setup(r => r.UpdateWorkspaceItem(It.IsAny<IContextualResourceModel>(), It.Is<bool>(b => b))).Verifiable();

                SetupImportServiceForPersistenceTests(wsiRepo);

                var resourceID = Guid.NewGuid();
                var serverID = Guid.NewGuid();

                #region Setup resourceModel

                var resourceRepo = new Mock<IResourceRepository>();
                resourceRepo.Setup(r => r.Save(It.IsAny<IResourceModel>())).Verifiable();

                var envConn = new Mock<IEnvironmentConnection>();
                var env = new Mock<IEnvironmentModel>();
                env.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
                env.Setup(e => e.Connection).Returns(envConn.Object);

                var resourceModel = new Mock<IContextualResourceModel>();
                resourceModel.Setup(m => m.Environment).Returns(env.Object);
                resourceModel.Setup(m => m.ID).Returns(resourceID);

                #endregion

                var workflowHelper = new Mock<IWorkflowHelper>();
                var designerViewModel = new WorkflowDesignerViewModel(resourceModel.Object, workflowHelper.Object, false);
                var contextViewModel = new WorkSurfaceContextViewModel(
                    new WorkSurfaceKey { ResourceID = resourceID, ServerID = serverID, WorkSurfaceContext = designerViewModel.WorkSurfaceContext },
                    designerViewModel);

                var envRepo = new Mock<IEnvironmentRepository>();
                var viewModel = new MainViewModelPersistenceMock(envRepo.Object, false);
                viewModel.Items.Add(contextViewModel);

                viewModel.TestClose();

                wsiRepo.Verify(r => r.UpdateWorkspaceItem(It.IsAny<IContextualResourceModel>(), It.Is<bool>(b => b)));
                resourceRepo.Verify(r => r.Save(It.IsAny<IResourceModel>()));
            }
        }
Пример #15
0
        public void MainViewModelDeactivateItemWithPreviousItemOpenExpectedActiveItemToBePreviousItem()
        {
            lock (syncroot)
            {
                var wsiRepo = new Mock<IWorkspaceItemRepository>();
                wsiRepo.Setup(r => r.WorkspaceItems).Returns(() => new List<IWorkspaceItem>());
                wsiRepo.Setup(r => r.Write()).Verifiable();

                #region Setup ImportService - GRRR!

                var importServiceContext = new ImportServiceContext();
                ImportService.CurrentContext = importServiceContext;
                ImportService.Initialize(new List<ComposablePartCatalog>
                {
                    new FullTestAggregateCatalog()
                });
                ImportService.AddExportedValueToContainer(wsiRepo.Object);
                ImportService.AddExportedValueToContainer(new Mock<IEventAggregator>().Object);

                #endregion

                var envRepo = new Mock<IEnvironmentRepository>();
                var mockMainViewModel = new MainViewModelPersistenceMock(envRepo.Object, false);
                mockMainViewModel.EventAggregator = ImportService.GetExportValue<IEventAggregator>();
                var resourceID = Guid.NewGuid();
                var serverID = Guid.NewGuid();

                #region Setup WorkSurfaceContextViewModel1

                var resourceRepo = new Mock<IResourceRepository>();
                resourceRepo.Setup(r => r.Save(It.IsAny<IResourceModel>())).Verifiable();

                var envConn = new Mock<IEnvironmentConnection>();
                var env = new Mock<IEnvironmentModel>();
                env.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
                env.Setup(e => e.Connection).Returns(envConn.Object);

                var resourceModel = new Mock<IContextualResourceModel>();
                resourceModel.Setup(m => m.Environment).Returns(env.Object);
                resourceModel.Setup(m => m.ID).Returns(resourceID);

                var workflowHelper = new Mock<IWorkflowHelper>();
                var designerViewModel = new WorkflowDesignerViewModel(resourceModel.Object, workflowHelper.Object, false);
                var contextViewModel1 = new WorkSurfaceContextViewModel(
                    new WorkSurfaceKey { ResourceID = resourceID, ServerID = serverID, WorkSurfaceContext = designerViewModel.WorkSurfaceContext },
                    designerViewModel);

                #endregion

                mockMainViewModel.Items.Add(contextViewModel1);

                serverID = Guid.NewGuid();
                resourceID = Guid.NewGuid();

                mockMainViewModel.PopupProvider = Dev2MockFactory.CreateIPopup(MessageBoxResult.No).Object;

                mockMainViewModel.ActivateItem(mockMainViewModel.Items[0]);
                mockMainViewModel.ActivateItem(mockMainViewModel.Items[1]);
                mockMainViewModel.CallDeactivate(mockMainViewModel.Items[1]);
                Assert.AreEqual(mockMainViewModel.Items[0], mockMainViewModel.ActiveItem);
            }
        }
Пример #16
0
        static WorkflowDesignerViewModel CreateWorkflowDesignerViewModel(IEventAggregator eventPublisher, IContextualResourceModel resourceModel, IWorkflowHelper workflowHelper = null, bool createDesigner = true, string helperText = null)
        {
            eventPublisher = eventPublisher ?? new Mock<IEventAggregator>().Object;

            var popupController = new Mock<IPopupController>();

            if (workflowHelper == null)
            {
                var wh = new Mock<IWorkflowHelper>();
                wh.Setup(h => h.CreateWorkflow(It.IsAny<string>())).Returns(() => new ActivityBuilder { Implementation = new DynamicActivity() });
                if (helperText != null)
                {
                    wh.Setup(h => h.SanitizeXaml(It.IsAny<StringBuilder>())).Returns(new StringBuilder(helperText));
                }
                workflowHelper = wh.Object;
            }

            var viewModel = new WorkflowDesignerViewModel(eventPublisher, resourceModel, workflowHelper, popupController.Object, new TestAsyncWorker(), createDesigner, _isDesignerInited, false);

            _isDesignerInited = true;

            return viewModel;
        }
Пример #17
0
        public void MainViewModelOnDeactivateWithTrueExpectedSavesResourceModels_WhenEnvironmentNotConnectedDoesNotCallSave()
        {
            var wsiRepo = new Mock<IWorkspaceItemRepository>();
            wsiRepo.Setup(r => r.WorkspaceItems).Returns(() => new List<IWorkspaceItem>());
            wsiRepo.Setup(r => r.UpdateWorkspaceItem(It.IsAny<IContextualResourceModel>(), It.Is<bool>(b => b))).Verifiable();

            SetupImportServiceForPersistenceTests(wsiRepo);

            var resourceID = Guid.NewGuid();
            var serverID = Guid.NewGuid();

            #region Setup resourceModel

            var resourceRepo = new Mock<IResourceRepository>();
            resourceRepo.Setup(r => r.Save(It.IsAny<IResourceModel>())).Verifiable();

            var envConn = new Mock<IEnvironmentConnection>();
            var env = new Mock<IEnvironmentModel>();
            envConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
            env.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
            env.Setup(e => e.Connection).Returns(envConn.Object);
            env.Setup(e => e.IsConnected).Returns(false);

            var resourceModel = new Mock<IContextualResourceModel>();
            resourceModel.Setup(m => m.Environment).Returns(env.Object);
            resourceModel.Setup(m => m.ID).Returns(resourceID);
            resourceModel.Setup(m => m.ResourceName).Returns("Some resource name 5");
            #endregion

            Mock<IPopupController> mockPopUp = Dev2MockFactory.CreateIPopup(MessageBoxResult.No);
            var workflowHelper = new Mock<IWorkflowHelper>();
            var designerViewModel = new WorkflowDesignerViewModel(new Mock<IEventAggregator>().Object, resourceModel.Object, workflowHelper.Object, mockPopUp.Object, new TestAsyncWorker(), false);
            var contextViewModel = new WorkSurfaceContextViewModel(
                new WorkSurfaceKey { ResourceID = resourceID, ServerID = serverID, WorkSurfaceContext = designerViewModel.WorkSurfaceContext },
                designerViewModel);

            var envRepo = new Mock<IEnvironmentRepository>();
            envRepo.Setup(r => r.All()).Returns(new[] { env.Object });
            envRepo.Setup(e => e.Source).Returns(env.Object);
            envRepo.Setup(r => r.ReadSession()).Returns(new[] { env.Object.ID });
            var viewModel = new MainViewModelPersistenceMock(envRepo.Object, false);
            viewModel.Items.Add(contextViewModel);

            viewModel.TestClose();

            wsiRepo.Verify(r => r.UpdateWorkspaceItem(It.IsAny<IContextualResourceModel>(), It.Is<bool>(b => b)), Times.Never());
            resourceRepo.Verify(r => r.Save(It.IsAny<IResourceModel>()), Times.Never());
        }
Пример #18
0
        public void MainViewModel_TryRemoveContext_Removes()
        {
            var wsiRepo = new Mock<IWorkspaceItemRepository>();
            wsiRepo.Setup(r => r.WorkspaceItems).Returns(() => new List<IWorkspaceItem>());
            wsiRepo.Setup(r => r.Write()).Verifiable();

            #region Setup ImportService - GRRR!

            SetupImportServiceForPersistenceTests(wsiRepo);

            #endregion

            var resourceRepo = new Mock<IResourceRepository>();
            resourceRepo.Setup(r => r.Save(It.IsAny<IResourceModel>())).Verifiable();
            var envRepo = new Mock<IEnvironmentRepository>();
            var envConn = new Mock<IEnvironmentConnection>();
            envConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
            var env = new Mock<IEnvironmentModel>();
            env.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
            env.Setup(e => e.Connection).Returns(envConn.Object);
            envRepo.Setup(r => r.All()).Returns(new List<IEnvironmentModel>(new[] { env.Object }));
            envRepo.Setup(r => r.Source).Returns(env.Object);

            Mock<IAsyncWorker> asyncWorker = AsyncWorkerTests.CreateSynchronousAsyncWorker();
            var mockMainViewModel = new MainViewModelPersistenceMock(envRepo.Object, asyncWorker.Object);
            var resourceID = Guid.NewGuid();

            #region Setup WorkSurfaceContextViewModel1

            var resourceModel = new Mock<IContextualResourceModel>();
            resourceModel.Setup(m => m.Environment).Returns(env.Object);
            resourceModel.Setup(m => m.ID).Returns(resourceID);
            resourceModel.Setup(m => m.IsNewWorkflow).Returns(true);
            resourceModel.Setup(m => m.IsWorkflowSaved).Returns(true);
            resourceModel.Setup(m => m.ResourceName).Returns("Some resource name 2");
            var workflowHelper = new Mock<IWorkflowHelper>();
            var designerViewModel = new WorkflowDesignerViewModel(resourceModel.Object, workflowHelper.Object, false);
            var contextViewModel1 = new WorkSurfaceContextViewModel(
                new WorkSurfaceKey { ResourceID = resourceID, ServerID = Guid.Empty, WorkSurfaceContext = designerViewModel.WorkSurfaceContext },
                designerViewModel);

            #endregion

            mockMainViewModel.Items.Add(contextViewModel1);

            Mock<IPopupController> mockPopUp = Dev2MockFactory.CreateIPopup(MessageBoxResult.No);
            mockPopUp.Setup(m => m.Show()).Verifiable();

            mockMainViewModel.PopupProvider = mockPopUp.Object;

            mockMainViewModel.ActivateItem(mockMainViewModel.Items[0]);
            mockMainViewModel.ActivateItem(mockMainViewModel.Items[1]);
            mockMainViewModel.TryRemoveContext(mockMainViewModel.Items[1].ContextualResourceModel);
            Assert.AreEqual(mockMainViewModel.Items[0], mockMainViewModel.ActiveItem);
            mockPopUp.Verify(m => m.Show(), Times.Never());
        }
Пример #19
0
        public void MainViewModel_UnsavedWorkflowDialog_WhenXPressed_WorkflowRemainsOpen()
        {
            var wsiRepo = new Mock<IWorkspaceItemRepository>();
            wsiRepo.Setup(r => r.WorkspaceItems).Returns(() => new List<IWorkspaceItem>());
            wsiRepo.Setup(r => r.Write()).Verifiable();

            #region Setup ImportService - GRRR!

            SetupImportServiceForPersistenceTests(wsiRepo);

            #endregion

            var envRepo = new Mock<IEnvironmentRepository>();
            var resourceRepo = new Mock<IResourceRepository>();
            resourceRepo.Setup(r => r.Save(It.IsAny<IResourceModel>())).Verifiable();

            var envConn = new Mock<IEnvironmentConnection>();
            var env = new Mock<IEnvironmentModel>();
            envConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
            env.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
            env.Setup(e => e.Connection).Returns(envConn.Object);
            envRepo.Setup(r => r.All()).Returns(new[] { env.Object });
            envRepo.Setup(e => e.Source).Returns(env.Object);
            envRepo.Setup(r => r.ReadSession()).Returns(new[] { env.Object.ID });
            Mock<IAsyncWorker> asyncWorker = AsyncWorkerTests.CreateSynchronousAsyncWorker();
            var mockMainViewModel = new MainViewModelPersistenceMock(envRepo.Object, asyncWorker.Object, false);
            var resourceID = Guid.NewGuid();
            var serverID = Guid.NewGuid();

            #region Setup WorkSurfaceContextViewModel1

            var resourceModel = new Mock<IContextualResourceModel>();
            resourceModel.Setup(m => m.Environment).Returns(env.Object);
            resourceModel.Setup(m => m.ID).Returns(resourceID);
            resourceModel.Setup(r => r.IsAuthorized(AuthorizationContext.Contribute)).Returns(true);
            resourceModel.Setup(m => m.ResourceName).Returns("Some resource name 3");
            Mock<IPopupController> mockPopUp = Dev2MockFactory.CreateIPopup(MessageBoxResult.No);
            mockPopUp.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButton>(), It.IsAny<MessageBoxImage>(), It.IsAny<string>())).Verifiable();
            var workflowHelper = new Mock<IWorkflowHelper>();
            var designerViewModel = new WorkflowDesignerViewModel(new Mock<IEventAggregator>().Object, resourceModel.Object, workflowHelper.Object, mockPopUp.Object, new TestAsyncWorker(), false);
            var contextViewModel1 = new WorkSurfaceContextViewModel(
                new WorkSurfaceKey { ResourceID = resourceID, ServerID = serverID, WorkSurfaceContext = designerViewModel.WorkSurfaceContext },
                designerViewModel);

            #endregion

            mockMainViewModel.Items.Add(contextViewModel1);
            mockMainViewModel.PopupProvider = mockPopUp.Object;

            mockMainViewModel.ActivateItem(mockMainViewModel.Items[0]);
            mockMainViewModel.ActivateItem(mockMainViewModel.Items[1]);
            mockMainViewModel.CallDeactivate(mockMainViewModel.Items[1]);
            Assert.AreEqual(mockMainViewModel.Items[1], mockMainViewModel.ActiveItem);
            mockPopUp.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButton>(), It.IsAny<MessageBoxImage>(), It.IsAny<string>()), Times.Once());
        }
Пример #20
0
 public static void AddDesignerAttributes(WorkflowDesignerViewModel workflowVm, bool liteInit)
 {
     workflowVm.InitializeDesigner(DesignerAttributes, liteInit);
 }
Пример #21
0
 public static void AddDesignerAttributes(WorkflowDesignerViewModel workflowVm) => AddDesignerAttributes(workflowVm, false);