Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }