TestCheckIfRemoteWorkflowAndSetProperties() public méthode

public TestCheckIfRemoteWorkflowAndSetProperties ( DsfActivity dsfActivity, IContextualResourceModel resource, IEnvironmentModel environmentModel ) : void
dsfActivity DsfActivity
resource IContextualResourceModel
environmentModel IEnvironmentModel
Résultat void
        public void CheckIfRemoteWorkflowAndSetPropertiesExpectedServiceUriToBeNull()
        {
            const string ServiceUri = "http://localhost:1234/";
            var resourceEnvironmentID = Guid.NewGuid();
            var envId = Guid.NewGuid();
            var mockResourceModel = Dev2MockFactory.SetupResourceModelMock();
            var mockWorkflowHelper = new Mock<IWorkflowHelper>();
            var environmentRepository = SetupEnvironmentRepo(Guid.Empty); // Set the active environment
            var testAct = DsfActivityFactory.CreateDsfActivity(mockResourceModel.Object, new DsfActivity(), true, environmentRepository, true);
            var mockEnv = Dev2MockFactory.SetupEnvironmentModel(mockResourceModel, null);
            mockEnv.Setup(c => c.ID).Returns(envId);
            mockResourceModel.Setup(c => c.Environment).Returns(mockEnv.Object);
            var testClass = new WorkflowDesignerViewModelMock(mockResourceModel.Object, mockWorkflowHelper.Object);
            testClass.TestCheckIfRemoteWorkflowAndSetProperties(testAct, mockResourceModel.Object, mockEnv.Object);
            Assert.IsTrue(testAct.ServiceUri == null);
            Assert.IsTrue(testAct.ServiceServer == Guid.Empty);

            var contextEnvironment = new Mock<IEnvironmentModel>();
            contextEnvironment.Setup(e => e.ID).Returns(resourceEnvironmentID);

            var activity = new DsfActivity();
            var workflow = new ActivityBuilder { Implementation = activity };

            #region Setup resourceModel

            var resourceRep = new Mock<IResourceRepository>();
            resourceRep.Setup(r => r.All()).Returns(new List<IResourceModel>());

            var resourceModel = new Mock<IContextualResourceModel>();
            resourceModel.Setup(m => m.Environment.ResourceRepository).Returns(resourceRep.Object);
            resourceModel.Setup(m => m.ResourceType).Returns(ResourceType.WorkflowService);
            resourceModel.Setup(m => m.Environment.ID).Returns(resourceEnvironmentID);
            resourceModel.Setup(m => m.Environment.Connection.WebServerUri).Returns(new Uri(ServiceUri));
            resourceModel.Setup(m => m.ResourceName).Returns("Some resource name 1");
            #endregion

            #region Setup viewModel

            var workflowHelper = new Mock<IWorkflowHelper>();
            workflowHelper.Setup(h => h.CreateWorkflow(It.IsAny<string>())).Returns(workflow);

            var viewModel = new WorkflowDesignerViewModelMock(resourceModel.Object, workflowHelper.Object);
            // not necessary to invoke:  viewModel.InitializeDesigner(new Dictionary<Type, Type>());

            #endregion

            viewModel.TestCheckIfRemoteWorkflowAndSetProperties(activity, resourceModel.Object, contextEnvironment.Object);

            viewModel.Dispose();

            Assert.IsNull(activity.ServiceUri);
            Assert.AreEqual(Guid.Empty, activity.ServiceServer);
        }