示例#1
0
        public void WfExecutionContainer_OnConstruction_ShouldNotThrowException()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                var obj = new Mock <IDSFDataObject>();
                var dev2WorkflowSettings = new Mock <Dev2.Common.Interfaces.IDev2WorkflowSettings>();
                dev2WorkflowSettings.Setup(o => o.EnableDetailedLogging).Returns(false);
                dev2WorkflowSettings.Setup(o => o.ExecutionLogLevel).Returns(LogLevel.ERROR.ToString);
                obj.Setup(o => o.Settings).Returns(dev2WorkflowSettings.Object);
                var workSpace     = new Mock <IWorkspace>();
                var channel       = new Mock <IEsbChannel>();
                var serviceAction = new ServiceAction();

                var wfExecutionContainer = new WfExecutionContainer(serviceAction, obj.Object, workSpace.Object, channel.Object);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            //---------------Test Result -----------------------
        }
示例#2
0
        [DoNotParallelize]//CustomContainer.Register is not threadsafe
        public void WfExecutionContainer_LogStopExecutionState()
        {
            var serviceAction  = new ServiceAction();
            var mockDataObject = new Mock <IDSFDataObject>();

            var dev2WorkflowSettings = new Mock <Common.Interfaces.IDev2WorkflowSettings>();

            dev2WorkflowSettings.Setup(o => o.EnableDetailedLogging).Returns(true);
            dev2WorkflowSettings.Setup(o => o.ExecutionLogLevel).Returns(LogLevel.DEBUG.ToString);
            mockDataObject.Setup(o => o.Settings).Returns(dev2WorkflowSettings.Object);

            var mockExecutionEnvironment = new Mock <IExecutionEnvironment>();

            mockExecutionEnvironment.Setup(o => o.Eval(It.IsAny <string>(), It.IsAny <int>()))
            .Returns(CommonFunctions.WarewolfEvalResult.NewWarewolfAtomListresult(new WarewolfAtomList <DataStorage.WarewolfAtom>(DataStorage.WarewolfAtom.NewDataString("Value"))))
            .Verifiable();
            mockExecutionEnvironment.Setup(o => o.FetchErrors()).Returns("Error").Verifiable();

            mockDataObject.Setup(o => o.Environment)
            .Returns(mockExecutionEnvironment.Object);
            mockDataObject.SetupGet(o => o.Environment.AllErrors)
            .Returns(new HashSet <string> {
                "2nd false error from WfExecutionContainerTests"
            });
            mockDataObject.SetupGet(o => o.Environment.Errors)
            .Returns(new HashSet <string> {
                "1st false error from WfExecutionContainerTests"
            });

            var mockStateNotifier = new Mock <IStateNotifier>();

            mockDataObject.Setup(o => o.StopExecution).Returns(true);
            mockDataObject.Setup(o => o.StateNotifier).Returns(mockStateNotifier.Object);

            var mockWorkspace        = new Mock <IWorkspace>();
            var mockEsbChannel       = new Mock <IEsbChannel>();
            var mockExecutionManager = new Mock <IExecutionManager>();

            mockStateNotifier.Setup(o => o.LogStopExecutionState(It.IsAny <IDev2Activity>()))
            .Verifiable();

            var logManagerMock = new Mock <IStateNotifierFactory>();

            logManagerMock.Setup(o => o.New(It.IsAny <IDSFDataObject>())).Returns(mockStateNotifier.Object);

            CustomContainer.Register <IExecutionManager>(mockExecutionManager.Object);
            CustomContainer.Register <IStateNotifierFactory>(logManagerMock.Object);
            var wfExecutionContainer = new WfExecutionContainer(serviceAction, mockDataObject.Object, mockWorkspace.Object, mockEsbChannel.Object);

            wfExecutionContainer.Eval(FlowchartProcess, mockDataObject.Object, 0);

            mockStateNotifier.Verify(o => o.LogStopExecutionState(It.IsAny <IDev2Activity>()), Times.Exactly(1));
            mockStateNotifier.Verify(o => o.LogExecuteCompleteState(It.IsAny <IDev2Activity>()), Times.Never);
        }
示例#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 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);
        }
示例#4
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);
            }
        }
        public void WfExecutionContainerExecuteInvokesWorkflowHelperCompileExpressions()
        {
            var sa         = new ServiceAction();
            var dataObj    = new Mock <IDSFDataObject>();
            var workspace  = new Mock <IWorkspace>();
            var esbChannel = new Mock <IEsbChannel>();

            var wh = new Mock <IWorkflowHelper>();

            wh.Setup(h => h.CompileExpressions(It.IsAny <DynamicActivity>())).Verifiable();

            var           exec = new WfExecutionContainer(sa, dataObj.Object, workspace.Object, esbChannel.Object, wh.Object);
            ErrorResultTO errors;

            exec.Execute(out errors);
            wh.Verify(h => h.CompileExpressions(It.IsAny <DynamicActivity>()));
        }
示例#6
0
        public void WfExecutionContainer_ExecuteNode_WhenSeverSettings_EnableDetailedLogging_IsTrue_ShouldRunLogActivityExecuteStateAndLogExecuteCompleteState()
        {
            //--------------Arrange------------------------------
            var dataObjectMock           = new Mock <IDSFDataObject>();
            var workSpaceMock            = new Mock <IWorkspace>();
            var esbChannelMock           = new Mock <IEsbChannel>();
            var executionEnvironmentMock = new Mock <IExecutionEnvironment>();
            var serviceAction            = new ServiceAction();
            var mockStateNotifier        = new Mock <IStateNotifier>();
            var mockExecutionManager     = new Mock <IExecutionManager>();

            var dev2WorkflowSettings = new Mock <Dev2.Common.Interfaces.IDev2WorkflowSettings>();

            dev2WorkflowSettings.Setup(o => o.EnableDetailedLogging).Returns(true);
            dev2WorkflowSettings.Setup(o => o.ExecutionLogLevel).Returns(LogLevel.DEBUG.ToString);
            executionEnvironmentMock.Setup(environment => environment.AllErrors).Returns(new HashSet <string>());
            executionEnvironmentMock.Setup(environment => environment.Errors).Returns(new HashSet <string>());
            dataObjectMock.Setup(o => o.Environment.FetchErrors())
            .Returns("");

            dataObjectMock.SetupGet(o => o.Environment).Returns(executionEnvironmentMock.Object);
            dataObjectMock.Setup(o => o.StopExecution).Returns(false);
            dataObjectMock.Setup(o => o.Settings).Returns(dev2WorkflowSettings.Object);
            dataObjectMock.Setup(o => o.StateNotifier).Returns(mockStateNotifier.Object);

            mockStateNotifier.Setup(o => o.LogActivityExecuteState(It.IsAny <IDev2Activity>())).Verifiable();
            mockStateNotifier.Setup(o => o.LogExecuteCompleteState(It.IsAny <IDev2Activity>())).Verifiable();

            var logManagerMock = new Mock <IStateNotifierFactory>();

            logManagerMock.Setup(o => o.New(It.IsAny <IDSFDataObject>())).Returns(mockStateNotifier.Object);

            CustomContainer.Register <IExecutionManager>(mockExecutionManager.Object);
            CustomContainer.Register <IStateNotifierFactory>(logManagerMock.Object);
            var wfExecutionContainer = new WfExecutionContainer(serviceAction, dataObjectMock.Object, workSpaceMock.Object, esbChannelMock.Object);

            //--------------Act----------------------------------
            wfExecutionContainer.Eval(FlowchartProcess, dataObjectMock.Object, 0);

            //--------------Assert-------------------------------
            Assert.IsNull(dataObjectMock.Object.ExecutionException);
            mockStateNotifier.Verify(o => o.LogExecuteCompleteState(It.IsAny <IDev2Activity>()), Times.Once);
            mockStateNotifier.Verify(o => o.Dispose(), Times.Once);
            mockExecutionManager.Verify(o => o.CompleteExecution(), Times.Once);
        }
示例#7
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);
        }
示例#8
0
        public void WfExecutionContainer_ExecuteNode_CheckWhenDataObjectStopExecutionIsFalse_ShouldEmptyExecutionExceptionInDataObject()
        {
            //--------------Arrange------------------------------
            var dataObjectMock       = new Mock <IDSFDataObject>();
            var workSpaceMock        = new Mock <IWorkspace>();
            var esbChannelMock       = new Mock <IEsbChannel>();
            var executionEnvironment = new Mock <ExecutionEnvironment>();
            var serviceAction        = new ServiceAction();


            dataObjectMock.SetupAllProperties();
            dataObjectMock.SetupGet(o => o.Environment).Returns(executionEnvironment.Object);
            dataObjectMock.Setup(o => o.StopExecution).Returns(false);

            var wfExecutionContainer = new WfExecutionContainer(serviceAction, dataObjectMock.Object, workSpaceMock.Object, esbChannelMock.Object);

            //--------------Act----------------------------------
            wfExecutionContainer.Eval(FlowchartProcess, dataObjectMock.Object, 0);

            //--------------Assert-------------------------------
            Assert.IsNull(dataObjectMock.Object.ExecutionException);
        }
示例#9
0
        public void WfExecutionContainer_ExecuteNode_CheckWhenDataObjectStopExecutionIsTrue_ShouldNotEmptyExecutionExceptionInDataObject()
        {
            //--------------Arrange------------------------------
            var dataObjectMock       = new Mock <IDSFDataObject>();
            var workSpaceMock        = new Mock <IWorkspace>();
            var esbChannelMock       = new Mock <IEsbChannel>();
            var executionEnvironment = new Mock <ExecutionEnvironment>();
            var serviceAction        = new ServiceAction();

            dataObjectMock.SetupAllProperties();
            dataObjectMock.SetupGet(o => o.Environment).Returns(executionEnvironment.Object);
            dataObjectMock.Setup(o => o.StopExecution).Returns(true);

            var wfExecutionContainer = new WfExecutionContainer(serviceAction, dataObjectMock.Object, workSpaceMock.Object, esbChannelMock.Object);

            //--------------Act----------------------------------
            wfExecutionContainer.Eval(FlowchartProcess, dataObjectMock.Object, 0);

            //--------------Assert-------------------------------
            Assert.IsNotNull(dataObjectMock.Object.ExecutionException);
            Assert.AreEqual(dataObjectMock.Object.ExecutionException.Message, "An error occurred while formatting a number, an invalid value of '' was returned from the rounding function.");
        }
        public void OnConstruction_ShouldNotThrowException()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                var obj           = new Mock <IDSFDataObject>();
                var workSpace     = new Mock <IWorkspace>();
                var channel       = new Mock <IEsbChannel>();
                var serviceAction = new ServiceAction();

                var wfExecutionContainer = new WfExecutionContainer(serviceAction, obj.Object, workSpace.Object, channel.Object);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            //---------------Test Result -----------------------
        }
示例#11
0
        private EsbExecutionContainer GenerateContainer(ServiceAction serviceAction, IDSFDataObject dataObj, IWorkspace theWorkspace)
        {
            // set the ID for later use ;)
            dataObj.WorkspaceID = _workspace.ID;

            EsbExecutionContainer result = null;

            switch (serviceAction.ActionType)
            {
            case Common.Interfaces.Core.DynamicServices.enActionType.InvokeManagementDynamicService:
                result = new InternalServiceContainer(serviceAction, dataObj, theWorkspace, _esbChannel, _request);
                break;

            case Common.Interfaces.Core.DynamicServices.enActionType.InvokeStoredProc:
                result = new DatabaseServiceContainer(serviceAction, dataObj, theWorkspace, _esbChannel);
                break;

            case Common.Interfaces.Core.DynamicServices.enActionType.InvokeWebService:
                result = new WebServiceContainer(serviceAction, dataObj, theWorkspace, _esbChannel);
                break;

            case Common.Interfaces.Core.DynamicServices.enActionType.Plugin:
                result = new PluginServiceContainer(serviceAction, dataObj, theWorkspace, _esbChannel);
                break;

            case Common.Interfaces.Core.DynamicServices.enActionType.Workflow:
                result = new WfExecutionContainer(serviceAction, dataObj, theWorkspace, _esbChannel);
                break;

            case Common.Interfaces.Core.DynamicServices.enActionType.RemoteService:
                result = new RemoteWorkflowExecutionContainer(serviceAction, dataObj, null, _esbChannel);
                break;
            }

            return(result);
        }
示例#12
0
        public void WfExecutionContainer_ExecuteNode_WhenSeverSettings_EnableDetailedLogging_IsTrue_ShouldRunLogExecuteException()
        {
            //--------------Arrange------------------------------
            var dataObjectMock           = new Mock <IDSFDataObject>();
            var workSpaceMock            = new Mock <IWorkspace>();
            var esbChannelMock           = new Mock <IEsbChannel>();
            var executionEnvironmentMock = new Mock <IExecutionEnvironment>();
            var serviceAction            = new ServiceAction();
            var mockStateNotifier        = new Mock <IStateNotifier>();
            var mockExecutionManager     = new Mock <IExecutionManager>();
            var activityParserMock       = new Mock <IActivityParser>();
            var activityMock             = new Mock <IDev2Activity>();

            var dev2WorkflowSettings = new Mock <Dev2.Common.Interfaces.IDev2WorkflowSettings>();

            dev2WorkflowSettings.Setup(o => o.EnableDetailedLogging).Returns(true);
            dev2WorkflowSettings.Setup(o => o.ExecutionLogLevel).Returns(LogLevel.DEBUG.ToString);
            var atomList = new WarewolfAtomList <DataStorage.WarewolfAtom>(DataStorage.WarewolfAtom.Nothing);

            atomList.AddSomething(DataStorage.WarewolfAtom.NewDataString("Bob"));
            atomList.AddSomething(DataStorage.WarewolfAtom.NewDataString("Stub"));
            executionEnvironmentMock.Setup(environment => environment.Eval(It.IsAny <string>(), It.IsAny <int>())).Returns(CommonFunctions.WarewolfEvalResult.NewWarewolfAtomListresult(atomList));
            executionEnvironmentMock.Setup(o => o.AddError(It.IsAny <string>())).Verifiable();

            dataObjectMock.SetupGet(o => o.Environment).Returns(executionEnvironmentMock.Object);
            dataObjectMock.SetupGet(o => o.Environment.AllErrors)
            .Returns(new HashSet <string> {
                "2nd false error from WfExecutionContainerTests"
            });
            dataObjectMock.SetupGet(o => o.Environment.Errors)
            .Returns(new HashSet <string> {
                "1st false error from WfExecutionContainerTests"
            });
            dataObjectMock.Setup(o => o.Environment.FetchErrors())
            .Returns("1st false error from WfExecutionContainerTests, 2nd false error from WfExecutionContainerTests");

            var falseException = new Exception("1st false error from WfExecutionContainerTests, 2nd false error from WfExecutionContainerTests");

            dataObjectMock.Setup(o => o.StopExecution).Returns(false);
            dataObjectMock.Setup(o => o.ExecutionException).Returns(falseException);
            dataObjectMock.Setup(o => o.Settings).Returns(dev2WorkflowSettings.Object);
            dataObjectMock.Setup(o => o.StateNotifier).Returns(mockStateNotifier.Object);

            mockStateNotifier.Setup(o => o.LogActivityExecuteState(It.IsAny <IDev2Activity>())).Verifiable();
            mockStateNotifier.Setup(o => o.LogExecuteException(It.IsAny <Exception>(), It.IsAny <IDev2Activity>())).Verifiable();

            var logManagerMock = new Mock <IStateNotifierFactory>();

            logManagerMock.Setup(o => o.New(It.IsAny <IDSFDataObject>())).Returns(mockStateNotifier.Object);

            activityMock.Setup(o => o.Execute(dataObjectMock.Object, 0)).Throws(falseException);
            activityParserMock.Setup(o => o.Parse(It.IsAny <DynamicActivity>())).Returns(activityMock.Object);

            CustomContainer.Register <IExecutionManager>(mockExecutionManager.Object);
            CustomContainer.Register <IStateNotifierFactory>(logManagerMock.Object);
            CustomContainer.Register <IActivityParser>(activityParserMock.Object);
            var wfExecutionContainer = new WfExecutionContainer(serviceAction, dataObjectMock.Object, workSpaceMock.Object, esbChannelMock.Object);

            //--------------Act----------------------------------
            wfExecutionContainer.Eval(FlowchartProcess, dataObjectMock.Object, 0);

            //--------------Assert-------------------------------
            Assert.IsNotNull(dataObjectMock.Object.ExecutionException);
            mockStateNotifier.Verify(o => o.LogExecuteException(falseException, activityMock.Object), Times.Once);
            mockStateNotifier.Verify(o => o.LogExecuteCompleteState(It.IsAny <IDev2Activity>()), Times.Never);
            mockStateNotifier.Verify(o => o.Dispose(), Times.Once);
            mockExecutionManager.Verify(o => o.CompleteExecution(), Times.Once);
        }
示例#13
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);
            }
        }
示例#14
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);
        }