Example #1
0
        public void ProcessDecisionContextActivityTaskCompletedTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.ActivityTaskCompleted;
            historyEvent.ActivityTaskCompletedEventAttributes = new ActivityTaskCompletedEventAttributes
            {
                ScheduledEventId = 1,
                StartedEventId   = 0,
                Result           = "Success!"
            };

            var newShcheduledEvent = Substitute.For <HistoryEvent>();

            newShcheduledEvent.EventType = EventType.ActivityTaskScheduled;
            newShcheduledEvent.ActivityTaskScheduledEventAttributes = new ActivityTaskScheduledEventAttributes
            {
                ActivityType = new ActivityType {
                    Name = "TestActivity", Version = "1.0"
                },
                ActivityId = "TestActivityID",
                Control    = "ImportantData"
            };


            //var activity = Substitute.For<ActivityBase<string, string>>("name", "taskList");

            //var activityStep = Substitute.For<WorkflowStep>();
            //activityStep.Action = activity;
            //activityStep.StepKey = "activityActionName";
            //activityStep.StepNumber = 0;
            //_workflowBase.Steps.Add(activityStep);


            //var activity1 = Substitute.For<ActivityBase<string, string>>("name1", "taskList");
            //var activityStep1 = Substitute.For<WorkflowStep>();
            //activityStep.Action = activity1;
            //activityStep.StepKey = "activityActionName";
            //activityStep.StepNumber = 1;
            //_workflowBase.Steps.Add(activityStep1);


            _processor = Substitute.For <SDK.Workflow.WorkflowEventsProcessor>(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf);

            _processor.FindEventTypeById(1).ReturnsForAnyArgs(info => newShcheduledEvent);

            _decisionContext = Substitute.For <WorkflowDecisionContext>();
            _processor.ProcessDecisionContext(historyEvent, _decisionContext);

            Assert.Equal(_decisionContext.ActivityId,
                         newShcheduledEvent.ActivityTaskScheduledEventAttributes.ActivityId);
            Assert.Equal(_decisionContext.Control, newShcheduledEvent.ActivityTaskScheduledEventAttributes.Control);
            Assert.Equal(_decisionContext.Input, newShcheduledEvent.ActivityTaskScheduledEventAttributes.Input);

            Assert.Equal(_decisionContext.ScheduledEventId,
                         historyEvent.ActivityTaskCompletedEventAttributes.ScheduledEventId);
            Assert.Equal(_decisionContext.StartedEventId,
                         historyEvent.ActivityTaskCompletedEventAttributes.StartedEventId);
            Assert.Equal(_decisionContext.DecisionType, historyEvent.EventType);
            Assert.Equal(_decisionContext.Result, historyEvent.ActivityTaskCompletedEventAttributes.Result);
        }
Example #2
0
        public void ProcessDecisionContextChildWorkflowExecutionFailedTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.ChildWorkflowExecutionFailed;
            historyEvent.ChildWorkflowExecutionFailedEventAttributes = new ChildWorkflowExecutionFailedEventAttributes
            {
                WorkflowType = new WorkflowType
                {
                    Name    = "WorkflowName",
                    Version = "Workflow Version"
                },

                Details = "It all should fail some time",
                Reason  = "Nobody cares",

                WorkflowExecution = new WorkflowExecution
                {
                    RunId = "FailedRunID"
                }
            };


            var newShcheduledEvent = Substitute.For <HistoryEvent>();

            newShcheduledEvent.EventType = EventType.ActivityTaskScheduled;
            newShcheduledEvent.StartChildWorkflowExecutionInitiatedEventAttributes = new StartChildWorkflowExecutionInitiatedEventAttributes
            {
                Control = "ImportantData",
                Input   = "FailedInput"
            };

            _processor = Substitute.For <SDK.Workflow.WorkflowEventsProcessor>(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf);

            _processor.FindEventTypeById(1).ReturnsForAnyArgs(info => newShcheduledEvent);

            _decisionContext = Substitute.For <WorkflowDecisionContext>();
            _processor.ProcessDecisionContext(historyEvent, _decisionContext);

            Assert.Equal(_decisionContext.DecisionType, historyEvent.EventType);
            Assert.Equal(_decisionContext.ChildWorkflowName, historyEvent.ChildWorkflowExecutionFailedEventAttributes.WorkflowType.Name);
            Assert.Equal(_decisionContext.ChildWorkflowVersion, historyEvent.ChildWorkflowExecutionFailedEventAttributes.WorkflowType.Version);
            Assert.Equal(_decisionContext.Reason, historyEvent.ChildWorkflowExecutionFailedEventAttributes.Reason);
            Assert.Equal(_decisionContext.Details, historyEvent.ChildWorkflowExecutionFailedEventAttributes.Details);
            Assert.Equal(_decisionContext.WorkflowExecRunId, historyEvent.ChildWorkflowExecutionFailedEventAttributes.WorkflowExecution.RunId);

            Assert.Equal(_decisionContext.Control, newShcheduledEvent.StartChildWorkflowExecutionInitiatedEventAttributes.Control);
            Assert.Equal(_decisionContext.Input, newShcheduledEvent.StartChildWorkflowExecutionInitiatedEventAttributes.Input);
        }
Example #3
0
        public void ProcessDecisionContextActivityTaskTimedOutTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.ActivityTaskTimedOut;
            historyEvent.ActivityTaskTimedOutEventAttributes = new ActivityTaskTimedOutEventAttributes
            {
                ScheduledEventId = 1,
                StartedEventId   = 0,
                TimeoutType      = ActivityTaskTimeoutType.HEARTBEAT,
                Details          = "Who does really care"
            };

            var newShcheduledEvent = Substitute.For <HistoryEvent>();

            newShcheduledEvent.EventType = EventType.ActivityTaskScheduled;
            newShcheduledEvent.ActivityTaskScheduledEventAttributes = new ActivityTaskScheduledEventAttributes
            {
                ActivityType = new ActivityType {
                    Name = "TestActivity", Version = "1.0"
                },
                ActivityId = "TestActivityID",
                Control    = "ImportantData"
            };

            _processor = Substitute.For <SDK.Workflow.WorkflowEventsProcessor>(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf);

            _processor.FindEventTypeById(1).ReturnsForAnyArgs(info => newShcheduledEvent);

            _decisionContext = Substitute.For <WorkflowDecisionContext>();
            _processor.ProcessDecisionContext(historyEvent, _decisionContext);


            Assert.Equal(_decisionContext.ActivityId,
                         newShcheduledEvent.ActivityTaskScheduledEventAttributes.ActivityId);
            Assert.Equal(_decisionContext.Control, newShcheduledEvent.ActivityTaskScheduledEventAttributes.Control);
            Assert.Equal(_decisionContext.Input, newShcheduledEvent.ActivityTaskScheduledEventAttributes.Input);

            Assert.Equal(_decisionContext.ScheduledEventId,
                         historyEvent.ActivityTaskTimedOutEventAttributes.ScheduledEventId);
            Assert.Equal(_decisionContext.StartedEventId,
                         historyEvent.ActivityTaskTimedOutEventAttributes.StartedEventId);
            Assert.Equal(_decisionContext.DecisionType, historyEvent.EventType);
            Assert.Equal(_decisionContext.TimeoutType, historyEvent.ActivityTaskTimedOutEventAttributes.TimeoutType);
            Assert.Equal(_decisionContext.Details, historyEvent.ActivityTaskTimedOutEventAttributes.Details);
        }
Example #4
0
        public void ProcessDecisionContextChildWorkflowExecutionCompletedTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.ChildWorkflowExecutionCompleted;
            historyEvent.ChildWorkflowExecutionCompletedEventAttributes = new ChildWorkflowExecutionCompletedEventAttributes
            {
                WorkflowType = new WorkflowType
                {
                    Name    = "WorkflowName",
                    Version = "Workflow Version"
                },
                Result = "Success!",
            };

            var newShcheduledEvent = Substitute.For <HistoryEvent>();

            newShcheduledEvent.EventType = EventType.ActivityTaskScheduled;
            newShcheduledEvent.StartChildWorkflowExecutionInitiatedEventAttributes = new StartChildWorkflowExecutionInitiatedEventAttributes
            {
                Control = "ImportantData",
            };


            _processor = Substitute.For <SDK.Workflow.WorkflowEventsProcessor>(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf);

            _processor.FindEventTypeById(1).ReturnsForAnyArgs(info => newShcheduledEvent);

            _decisionContext = Substitute.For <WorkflowDecisionContext>();
            _processor.ProcessDecisionContext(historyEvent, _decisionContext);


            Assert.Equal(_decisionContext.ChildWorkflowName, historyEvent.ChildWorkflowExecutionCompletedEventAttributes.WorkflowType.Name);
            Assert.Equal(_decisionContext.ChildWorkflowVersion, historyEvent.ChildWorkflowExecutionCompletedEventAttributes.WorkflowType.Version);
            Assert.Equal(_decisionContext.Result, historyEvent.ChildWorkflowExecutionCompletedEventAttributes.Result);

            Assert.Equal(_decisionContext.Control,
                         newShcheduledEvent.StartChildWorkflowExecutionInitiatedEventAttributes.Control);

            Assert.Equal(_decisionContext.DecisionType, historyEvent.EventType);
        }