public void RecsetWithStarExpectedXPaths_InsideForEach_ShouldRespect_UpdateValueForRecordsetIndex()
        {
            _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//type/method/@signature", 1));

            const string dataSplitPreDataList = "<ADL><xmlData/><recset1><field1/></recset1><recset2><field2/></recset2><OutVar1/><OutVar2/><OutVar3/><OutVar4/><OutVar5/></ADL>";
            var          act = new DsfXPathActivity {
                SourceString = Source, ResultsCollection = _resultsCollection
            };

            CurrentDl = dataSplitPreDataList;
            TestData  = "<root>" + dataSplitPreDataList + "</root>";

            if (CurrentDl == null)
            {
                CurrentDl = TestData;
            }
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = false,
                EnvironmentID            = new Guid(),
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl)
            };

            if (!string.IsNullOrEmpty(TestData))
            {
                ExecutionEnvironmentUtils.UpdateEnvironmentFromXmlPayload(dataObject, new StringBuilder(TestData), CurrentDl, 0);
            }



            List <string> expected = new List <string> {
                "void(object)", "void(object)",
                "void(Dev2.DynamicServices.IDynamicServiceObject, object)", "void(CommandLine.Text.HelpText)",
                "string()", "Unlimited.Applications.WebServer.Responses.CommunicationResponseWriter(object, string, string)"
            };
            string error;

            for (int i = 1; i < 4; i++)
            {
                act.Execute(dataObject, i);
            }

            List <string> actual = RetrieveAllRecordSetFieldValues(dataObject.Environment, "recset1", "field1", out error);

            Assert.IsNotNull(actual);
            Assert.AreEqual(3, actual.Count);
            Assert.AreEqual("Unlimited.Applications.WebServer.Responses.CommunicationResponseWriter(object, string, string)", actual[0]);
            Assert.AreEqual("Unlimited.Applications.WebServer.Responses.CommunicationResponseWriter(object, string, string)", actual[1]);
            Assert.AreEqual("Unlimited.Applications.WebServer.Responses.CommunicationResponseWriter(object, string, string)", actual[2]);
        }
        private static RemoteWorkflowExecutionContainerMock CreateExecutionContainer(IResourceCatalog resourceCatalog, string dataListShape, string dataListData, string webResponse, IWebRequestFactory webRequestFactory, IDSFDataObject dataObj)
        {
            ExecutionEnvironmentUtils.UpdateEnvironmentFromXmlPayload(dataObj, new StringBuilder(dataListData), dataListShape, 0);
            var sa         = new ServiceAction();
            var workspace  = new Mock <IWorkspace>();
            var esbChannel = new Mock <IEsbChannel>();

            var container = new RemoteWorkflowExecutionContainerMock(sa, dataObj, workspace.Object, esbChannel.Object,
                                                                     resourceCatalog, webRequestFactory)
            {
                GetRequestRespsonse = webResponse
            };

            return(container);
        }
        static RemoteWorkflowExecutionContainerMock CreateExecutionContainer(IResourceCatalog resourceCatalog, string dataListShape = "<DataList></DataList>", string dataListData = "")
        {
            var dataObj = new Mock <IDSFDataObject>();

            dataObj.Setup(d => d.EnvironmentID).Returns(_connection.ResourceID);
            dataObj.Setup(d => d.ServiceName).Returns("Test");
            dataObj.Setup(d => d.RemoteInvokeResultShape).Returns(new StringBuilder("<ADL><NumericGUID></NumericGUID></ADL>"));
            dataObj.Setup(d => d.Environment).Returns(new ExecutionEnvironment());
            ExecutionEnvironmentUtils.UpdateEnvironmentFromXmlPayload(dataObj.Object, new StringBuilder(dataListData), dataListShape, 0);
            var sa         = new ServiceAction();
            var workspace  = new Mock <IWorkspace>();
            var esbChannel = new Mock <IEsbChannel>();

            var container = new RemoteWorkflowExecutionContainerMock(sa, dataObj.Object, workspace.Object, esbChannel.Object, resourceCatalog)
            {
                GetRequestRespsonse = "<DataList><NumericGUID>74272317-2264-4564-3988-700350008298</NumericGUID></DataList>"
            };

            return(container);
        }
Ejemplo n.º 4
0
        protected IDSFDataObject ExecuteProcess(IDSFDataObject dataObject = null, bool isDebug = false, IEsbChannel channel = null, bool isRemoteInvoke = false, bool throwException = true, bool isDebugMode = false, Guid currentEnvironmentId = default(Guid), bool overrideRemote = false)
        {
            using (ServiceAction svc = new ServiceAction {
                Name = "TestAction", ServiceName = "UnitTestService"
            })
            {
                svc.SetActivity(FlowchartProcess);
                var mockChannel = new Mock <IEsbChannel>();

                if (CurrentDl == null)
                {
                    CurrentDl = TestData;
                }

                var errors = new ErrorResultTO();
                if (ExecutionId == Guid.Empty)
                {
                    if (dataObject != null)
                    {
                        dataObject.ExecutingUser = User;
                        dataObject.DataList      = new StringBuilder(CurrentDl);
                    }
                }

                if (errors.HasErrors())
                {
                    var errorString = errors.FetchErrors().Aggregate(string.Empty, (current, item) => current + item);

                    if (throwException)
                    {
                        throw new Exception(errorString);
                    }
                }

                if (dataObject == null)
                {
                    dataObject = new DsfDataObject(CurrentDl, ExecutionId)
                    {
                        // NOTE: WorkflowApplicationFactory.InvokeWorkflowImpl() will use HostSecurityProvider.Instance.ServerID
                        //       if this is NOT provided which will cause the tests to fail!
                        ServerID                 = Guid.NewGuid(),
                        ExecutingUser            = User,
                        IsDebug                  = isDebugMode,
                        EnvironmentID            = currentEnvironmentId,
                        IsRemoteInvokeOverridden = overrideRemote,
                        DataList                 = new StringBuilder(CurrentDl)
                    };
                }
                if (!string.IsNullOrEmpty(TestData))
                {
                    ExecutionEnvironmentUtils.UpdateEnvironmentFromXmlPayload(DataObject, new StringBuilder(TestData), CurrentDl, 0);
                }
                dataObject.IsDebug = isDebug;

                // we now need to set a thread ID ;)
                dataObject.ParentThreadID = 1;

                if (isRemoteInvoke)
                {
                    dataObject.RemoteInvoke    = true;
                    dataObject.RemoteInvokerID = Guid.NewGuid().ToString();
                }

                var esbChannel = mockChannel.Object;
                if (channel != null)
                {
                    esbChannel = channel;
                }
                dataObject.ExecutionToken = new ExecutionToken();
                var wfec = new WfExecutionContainer(svc, dataObject, WorkspaceRepository.Instance.ServerWorkspace, esbChannel);

                errors.ClearErrors();
                CustomContainer.Register <IActivityParser>(new ActivityParser());
                if (dataObject.ResourceID == Guid.Empty)
                {
                    dataObject.ResourceID = Guid.NewGuid();
                }
                dataObject.Environment = DataObject.Environment;
                wfec.Eval(FlowchartProcess, dataObject, 0);
                DataObject = dataObject;
                return(dataObject);
            }
        }