public void WorkflowStateGetLastExecContextTest() { var historyEvent = Substitute.For <HistoryEvent>(); historyEvent.EventId = 10; historyEvent.DecisionTaskCompletedEventAttributes = new DecisionTaskCompletedEventAttributes { ExecutionContext = _executionContext }; historyEvent.EventType = EventType.DecisionTaskCompleted; _decisionTask.Events.Add(historyEvent); _processor = new SDK.Workflow.WorkflowEventsProcessor(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf); var describeWorkflowExecutionRequest = Substitute.For <DescribeWorkflowExecutionRequest>(); describeWorkflowExecutionRequest.Domain = _pollforDecisionTaskRequest.Domain; describeWorkflowExecutionRequest.Execution = _decisionTask.WorkflowExecution; //_amazonSwf.DescribeWorkflowExecution(describeWorkflowExecutionRequest) // .ReturnsForAnyArgs( // info => // new DescribeWorkflowExecutionResponse() // { // HttpStatusCode = HttpStatusCode.OK, // WorkflowExecutionDetail = new WorkflowExecutionDetail() {LatestExecutionContext = _executionContext} // }); var result = _processor.GetLastExecContext(); AssertObjectEquals.PropertyValuesAreEqual(WorkflowStateSerializer.Deserialize(_executionContext), result); }
public WorkflowEventsProcessorTests() { _decisionTask = Substitute.For <DecisionTask>(); _decisionTask.WorkflowType = new WorkflowType { Name = "TestWorkflow", Version = "TestVersion" }; _decisionTask.WorkflowExecution = new WorkflowExecution { RunId = "TestRunId", WorkflowId = "" }; var results = new ConcurrentDictionary <int, string>(); results.AddOrUpdate(1, "TestResult", UpdateValueFactory); _executionContext = WorkflowStateSerializer.Serialize(new WorkflowState() { CurrentStepNumber = 1, NumberOfActions = 1, Results = results }); _pollforDecisionTaskRequest = Substitute.For <PollForDecisionTaskRequest>(); _pollforDecisionTaskRequest.Domain = "TestDomain"; _amazonSwf = Substitute.For <IAmazonSimpleWorkflow>(); _workflowBase = Substitute.For <WorkflowBase>("domain", "workflowName", "version", "taskList", _amazonSwf); var describeWorkflowExecutionRequest = Substitute.For <DescribeWorkflowExecutionRequest>(); describeWorkflowExecutionRequest.Domain = _pollforDecisionTaskRequest.Domain; describeWorkflowExecutionRequest.Execution = _decisionTask.WorkflowExecution; //_amazonSwf.DescribeWorkflowExecution(describeWorkflowExecutionRequest) // .ReturnsForAnyArgs( // info => // new DescribeWorkflowExecutionResponse() // { // HttpStatusCode = HttpStatusCode.OK, // WorkflowExecutionDetail = new WorkflowExecutionDetail() {LatestExecutionContext = _executionContext} // }); SDK.Workflow.WorkflowEventsProcessor processor = Substitute.For <SDK.Workflow.WorkflowEventsProcessor>(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf); processor.GetLastExecContext().ReturnsForAnyArgs(info => WorkflowStateSerializer.Deserialize(_executionContext)); //_workflowEventsIterator = Substitute.For<WorkflowEventsIterator>(_decisionTask, _pollforDecisionTaskRequest, // _amazonSwf); }
public void ProcessDecisionContextDecisionTaskCompletedTest([Frozen] HistoryEvent historyEvent) { historyEvent.EventType = EventType.DecisionTaskCompleted; historyEvent.DecisionTaskCompletedEventAttributes = new DecisionTaskCompletedEventAttributes { ScheduledEventId = 10, StartedEventId = 10, ExecutionContext = _executionContext }; _processor = new SDK.Workflow.WorkflowEventsProcessor(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf); _decisionContext = Substitute.For <WorkflowDecisionContext>(); _processor.ProcessDecisionContext(historyEvent, _decisionContext); AssertObjectEquals.PropertyValuesAreEqual(_decisionContext.ExecutionContext, WorkflowStateSerializer.Deserialize(_executionContext)); Assert.Equal(_decisionContext.StartedEventId, historyEvent.DecisionTaskCompletedEventAttributes.StartedEventId); Assert.Equal(_decisionContext.ScheduledEventId, historyEvent.DecisionTaskCompletedEventAttributes.ScheduledEventId); }