Пример #1
0
        public void WorkflowDesignerViewModel_LinkName_SavedDebugData_ShouldReturnUrlWithDataListUsingSavedData()
        {
            //------------Setup for test--------------------------
            var workflow = new ActivityBuilder
            {
                Implementation = new Flowchart
                {
                    StartNode = CreateFlowNode(Guid.NewGuid(), "CanSaveTest", true, typeof(TestActivity))
                }
            };

            #region Setup viewModel

            var resourceRep = new Mock<IResourceRepository>();
            resourceRep.Setup(r => r.All()).Returns(new List<IResourceModel>());
            resourceRep.Setup(r => r.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>())).Returns(new ExecuteMessage());
            resourceRep.Setup(repository => repository.Save(It.IsAny<IResourceModel>())).Verifiable();
            var resourceModel = new Mock<IContextualResourceModel>();
            var mockEnvironmentModel = new Mock<IEnvironmentModel>();
            var mockConnection = new Mock<IEnvironmentConnection>();
            mockConnection.Setup(connection => connection.IsConnected).Returns(true);
            mockConnection.Setup(connection => connection.WebServerUri).Returns(new Uri("http://myMachineName:3142"));
            mockEnvironmentModel.Setup(model => model.Connection).Returns(mockConnection.Object);
            resourceModel.Setup(m => m.Environment).Returns(mockEnvironmentModel.Object);
            resourceModel.Setup(m => m.Environment.IsConnected).Returns(true);
            resourceModel.Setup(m => m.Environment.ResourceRepository).Returns(resourceRep.Object);
            resourceModel.Setup(m => m.Environment.Connection).Returns(mockConnection.Object);
            resourceModel.Setup(model => model.IsNewWorkflow).Returns(true);
            resourceModel.Setup(model => model.Category).Returns("myservice");
            resourceModel.Setup(model => model.ResourceName).Returns("myservice");
            resourceModel.Setup(model => model.DataList).Returns(StringResourcesTest.DebugInputWindow_DataList);
            var workflowInputDataViewModel = WorkflowInputDataViewModel.Create(resourceModel.Object);
            workflowInputDataViewModel.LoadWorkflowInputs();
            workflowInputDataViewModel.WorkflowInputs[0].Value = "1";
            workflowInputDataViewModel.WorkflowInputs[1].Value = "2";
            workflowInputDataViewModel.DoSaveActions();
            var workflowHelper = new Mock<IWorkflowHelper>();
            workflowHelper.Setup(h => h.CreateWorkflow(It.IsAny<string>())).Returns(workflow);
            workflowHelper.Setup(helper => helper.SerializeWorkflow(It.IsAny<ModelService>())).Returns(new StringBuilder("my workflow"));
            var viewModel = new WorkflowDesignerViewModelMock(resourceModel.Object, workflowHelper.Object);
            viewModel.InitializeDesigner(new Dictionary<Type, Type>());
            resourceModel.SetupProperty(model => model.WorkflowXaml);

            #endregion
            //------------Assert Preconditions-------------------
            Assert.IsNull(resourceModel.Object.WorkflowXaml);
            //------------Execute Test---------------------------
            var workflowLink = viewModel.GetWorkflowLink();
            var displayWorkflowLink = viewModel.DisplayWorkflowLink;
            //------------Assert Results-------------------------
            Assert.AreEqual("http://mymachinename:3142/secure/myservice.json?scalar1=1&scalar2=2&wid=00000000-0000-0000-0000-000000000000", workflowLink);
            Assert.AreEqual("http://mymachinename:3142/secure/myservice.json?scalar1=1&scalar2=2", displayWorkflowLink);
            workflowInputDataViewModel.WorkflowInputs[0].Value = "";
            workflowInputDataViewModel.WorkflowInputs[1].Value = "";
            workflowInputDataViewModel.DoSaveActions();
        }
Пример #2
0
        public void WorkflowDesignerViewModel_LinkName_HasDataListNoInputs_ShouldReturnUrlEmptyDataListPortion()
        {
            //------------Setup for test--------------------------
            var workflow = new ActivityBuilder
            {
                Implementation = new Flowchart
                {
                    StartNode = CreateFlowNode(Guid.NewGuid(), "CanSaveTest", true, typeof(TestActivity))
                }
            };

            #region Setup viewModel

            var resourceRep = new Mock<IResourceRepository>();
            resourceRep.Setup(r => r.All()).Returns(new List<IResourceModel>());
            resourceRep.Setup(r => r.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>())).Returns(new ExecuteMessage());
            resourceRep.Setup(repository => repository.Save(It.IsAny<IResourceModel>())).Verifiable();
            var resourceModel = new Mock<IContextualResourceModel>();
            var mockEnvironmentModel = new Mock<IEnvironmentModel>();
            var mockConnection = new Mock<IEnvironmentConnection>();
            mockConnection.Setup(connection => connection.IsConnected).Returns(true);
            mockConnection.Setup(connection => connection.WebServerUri).Returns(new Uri("http://myMachineName:3142"));
            mockEnvironmentModel.Setup(model => model.Connection).Returns(mockConnection.Object);
            resourceModel.Setup(m => m.Environment).Returns(mockEnvironmentModel.Object);
            resourceModel.Setup(m => m.Environment.IsConnected).Returns(true);
            resourceModel.Setup(m => m.Environment.ResourceRepository).Returns(resourceRep.Object);
            resourceModel.Setup(m => m.Environment.Connection).Returns(mockConnection.Object);
            resourceModel.Setup(model => model.IsNewWorkflow).Returns(true);
            resourceModel.Setup(model => model.Category).Returns("myservice");
            resourceModel.Setup(model => model.ResourceName).Returns("myservice");
            resourceModel.Setup(model => model.DataList).Returns(StringResourcesTest.DebugInputWindow_NoInputs_XMLData);
            var workflowHelper = new Mock<IWorkflowHelper>();
            workflowHelper.Setup(h => h.CreateWorkflow(It.IsAny<string>())).Returns(workflow);
            workflowHelper.Setup(helper => helper.SerializeWorkflow(It.IsAny<ModelService>())).Returns(new StringBuilder("my workflow"));
            var mockPopController = new Mock<IPopupController>();
            mockPopController.Setup(controller => controller.ShowNoInputsSelectedWhenClickLink()).Verifiable();
            var viewModel = new WorkflowDesignerViewModelMock(resourceModel.Object, workflowHelper.Object, mockPopController.Object);
            viewModel.InitializeDesigner(new Dictionary<Type, Type>());
            resourceModel.SetupProperty(model => model.WorkflowXaml);

            #endregion
            //------------Assert Preconditions-------------------
            Assert.IsNull(resourceModel.Object.WorkflowXaml);
            //------------Execute Test---------------------------
            var workflowLink = viewModel.GetWorkflowLink();
            var displayWorkflowLink = viewModel.DisplayWorkflowLink;
            viewModel.OpenWorkflowLinkCommand.Execute("Do not perform action");
            //------------Assert Results-------------------------
            Assert.AreEqual("http://mymachinename:3142/secure/myservice.json?<DataList></DataList>&wid=00000000-0000-0000-0000-000000000000", workflowLink);
            Assert.AreEqual("http://mymachinename:3142/secure/myservice.json?<DataList></DataList>", displayWorkflowLink);
            mockPopController.Verify(controller => controller.ShowNoInputsSelectedWhenClickLink(), Times.Once());
        }