Exemplo n.º 1
0
        /// <summary>
        /// The ForEach Activity requires the data returned from an activity
        /// We will mock the DSF channel to return something that we expect is shaped.
        /// </summary>
        /// <returns></returns>
        public Mock <IEsbChannel> ExecuteForEachProcess(out IDSFDataObject dataObject, bool isDebug = false, int nestingLevel = 0)
        {
            var svc = new ServiceAction {
                Name = "ForEachTestAction", ServiceName = "UnitTestService"
            };
            var mockChannel = new Mock <IEsbChannel>();

            svc.SetActivity(FlowchartProcess);

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

            Compiler = DataListFactory.CreateDataListCompiler();
            ErrorResultTO errors;
            Guid          exId = Compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), new StringBuilder(TestData), new StringBuilder(CurrentDl), out errors);


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

                throw new Exception(errorString);
            }

            dataObject = new DsfDataObject(CurrentDl, exId)
            {
                // NOTE: WorkflowApplicationFactory.InvokeWorkflowImpl() will use HostSecurityProvider.Instance.ServerID
                //       if this is NOT provided which will cause the tests to fail!
                ServerID            = Guid.NewGuid(),
                IsDebug             = isDebug,
                ForEachNestingLevel = nestingLevel,
                ParentThreadID      = 1
            };


            // we need to set this now ;)

            mockChannel.Setup(c => c.ExecuteSubRequest(It.IsAny <IDSFDataObject>(), It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), out errors)).Verifiable();

            WfExecutionContainer wfec = new WfExecutionContainer(svc, dataObject, Dev2.Workspaces.WorkspaceRepository.Instance.ServerWorkspace, mockChannel.Object);

            errors.ClearErrors();
            dataObject.DataListID = wfec.Execute(out errors);

            return(mockChannel);
        }
Exemplo n.º 2
0
        protected Mock <IEsbChannel> ExecuteForEachProcess(out IDSFDataObject dataObject, bool isDebug = false, int nestingLevel = 0)
        {
            using (ServiceAction svc = new ServiceAction {
                Name = "ForEachTestAction", ServiceName = "UnitTestService"
            })
            {
                var mockChannel = new Mock <IEsbChannel>();
                svc.SetActivity(FlowchartProcess);

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

                var errors = new ErrorResultTO();


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

                    throw new Exception(errorString);
                }

                dataObject = new DsfDataObject(CurrentDl, new Guid())
                {
                    // NOTE: WorkflowApplicationFactory.InvokeWorkflowImpl() will use HostSecurityProvider.Instance.ServerID
                    //       if this is NOT provided which will cause the tests to fail!
                    ServerID            = Guid.NewGuid(),
                    IsDebug             = isDebug,
                    ForEachNestingLevel = nestingLevel,
                    ParentThreadID      = 1
                };


                // we need to set this now ;)

                mockChannel.Setup(c => c.ExecuteSubRequest(It.IsAny <IDSFDataObject>(), It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), out errors, 0, false)).Verifiable();
                CustomContainer.Register <IActivityParser>(new ActivityParser());
                var wfec = new WfExecutionContainer(svc, dataObject, WorkspaceRepository.Instance.ServerWorkspace, mockChannel.Object);

                errors.ClearErrors();
                wfec.Eval(FlowchartProcess, dataObject, 0);

                return(mockChannel);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// The ForEach Activity requires the data returned from an activity
        /// We will mock the DSF channel to return something that we expect is shaped.
        /// </summary>
        /// <returns></returns>
        public void ExecuteForEachProcessForReal(out IDSFDataObject dataObject)
        {
            var svc = new ServiceAction {
                Name = "ForEachTestAction", ServiceName = "UnitTestService"
            };
            IEsbChannel channel = new EsbServicesEndpoint();

            svc.SetActivity(FlowchartProcess);

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

            Compiler = DataListFactory.CreateDataListCompiler();
            ErrorResultTO errors;
            Guid          exId = Compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), new StringBuilder(TestData), new StringBuilder(CurrentDl), out errors);


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

                throw new Exception(errorString);
            }

            dataObject = new DsfDataObject(CurrentDl, exId)
            {
                // NOTE: WorkflowApplicationFactory.InvokeWorkflowImpl() will use HostSecurityProvider.Instance.ServerID
                //       if this is NOT provided which will cause the tests to fail!
                ServerID       = Guid.NewGuid(),
                ParentThreadID = 1
            };


            // we need to set this now ;)
            WfExecutionContainer wfec = new WfExecutionContainer(svc, dataObject, Dev2.Workspaces.WorkspaceRepository.Instance.ServerWorkspace, channel);

            errors.ClearErrors();
            dataObject.DataListID = wfec.Execute(out errors);
        }
Exemplo 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);
            }
        }
Exemplo n.º 5
0
        public dynamic 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)
        {
            var svc = new ServiceAction {
                Name = "TestAction", ServiceName = "UnitTestService"
            };

            svc.SetActivity(FlowchartProcess);
            Mock <IEsbChannel> mockChannel = new Mock <IEsbChannel>();

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

            var errors = new ErrorResultTO();

            if (ExecutionId == Guid.Empty)
            {
                Compiler = DataListFactory.CreateDataListCompiler();

                ExecutionId = Compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), new StringBuilder(TestData), new StringBuilder(CurrentDl), out errors);
                if (dataObject != null)
                {
                    dataObject.DataListID    = ExecutionId;
                    dataObject.ExecutingUser = User;
                    dataObject.DataList      = new StringBuilder(CurrentDl);
                }
            }

            if (errors.HasErrors())
            {
                string 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)
                };
            }
            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;
            }
            WfExecutionContainer wfec = new WfExecutionContainer(svc, dataObject, Dev2.Workspaces.WorkspaceRepository.Instance.ServerWorkspace, esbChannel);

            errors.ClearErrors();
            dataObject.DataListID = wfec.Execute(out errors);


            return(dataObject);
        }