/// <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); }
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>())); }
/// <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); }
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); }