Example #1
0
        public void ProcessDecisionContextStartChildWorkflowExecutionFailedTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.StartChildWorkflowExecutionFailed;
            historyEvent.StartChildWorkflowExecutionFailedEventAttributes = new StartChildWorkflowExecutionFailedEventAttributes
            {
                WorkflowType = new WorkflowType
                {
                    Name    = "WorkflowName",
                    Version = "1.0"
                },
                Cause   = "Nobody knows",
                Control = "Important Data"
            };

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

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

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

            Assert.Equal(_decisionContext.ChildWorkflowName, historyEvent.StartChildWorkflowExecutionFailedEventAttributes.WorkflowType.Name);
            Assert.Equal(_decisionContext.ChildWorkflowVersion, historyEvent.StartChildWorkflowExecutionFailedEventAttributes.WorkflowType.Version);
            Assert.Equal(_decisionContext.Cause, historyEvent.StartChildWorkflowExecutionFailedEventAttributes.Cause);
            Assert.Equal(_decisionContext.Control, historyEvent.StartChildWorkflowExecutionFailedEventAttributes.Control);
        }
Example #2
0
        public void ProcessDecisionContextTimerCanceledTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.TimerStarted;
            historyEvent.TimerStartedEventAttributes = new TimerStartedEventAttributes()
            {
                TimerId = "TestID",
            };

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

            historyEvent2.EventType = EventType.TimerCanceled;
            historyEvent2.TimerCanceledEventAttributes = new TimerCanceledEventAttributes()
            {
                TimerId = "TestID",
            };

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

            _decisionContext = Substitute.For <WorkflowDecisionContext>();
            _decisionContext.Timers["TestID"] = historyEvent.TimerStartedEventAttributes;

            _processor.ProcessDecisionContext(historyEvent2, _decisionContext);

            Assert.Equal(_decisionContext.DecisionType, historyEvent2.EventType);
            Assert.Equal(_decisionContext.DecisionType, historyEvent2.EventType);
            Assert.Equal(_decisionContext.TimerId, historyEvent2.TimerCanceledEventAttributes.TimerId);
            Assert.Equal(_decisionContext.CanceledTimers["TestID"], historyEvent2.TimerCanceledEventAttributes);
        }
Example #3
0
        public void ProcessDecisionContextChildWorkflowExecutionStartedTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.ChildWorkflowExecutionStarted;
            historyEvent.ChildWorkflowExecutionStartedEventAttributes = new ChildWorkflowExecutionStartedEventAttributes
            {
                WorkflowType = new WorkflowType
                {
                    Name    = "WorkflowName",
                    Version = "Workflow Version"
                },
                WorkflowExecution = new WorkflowExecution
                {
                    RunId      = "TestRunID",
                    WorkflowId = "TestWorkflowID"
                }
            };

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

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


            Assert.Equal(_decisionContext.DecisionType, historyEvent.EventType);
            Assert.Equal(_decisionContext.ChildWorkflowName,
                         historyEvent.ChildWorkflowExecutionStartedEventAttributes.WorkflowType.Name);
            Assert.Equal(_decisionContext.ChildWorkflowVersion,
                         historyEvent.ChildWorkflowExecutionStartedEventAttributes.WorkflowType.Version);
            Assert.Equal(_decisionContext.WorkflowExecRunId,
                         historyEvent.ChildWorkflowExecutionStartedEventAttributes.WorkflowExecution.RunId);
        }
Example #4
0
        public void ProcessDecisionContextScheduleActivityTaskFailedTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.ScheduleActivityTaskFailed;
            historyEvent.ScheduleActivityTaskFailedEventAttributes = new ScheduleActivityTaskFailedEventAttributes
            {
                ActivityType = new ActivityType {
                    Name = "TestActivity", Version = "1.0"
                },
                ActivityId = "TestActivityID",
                DecisionTaskCompletedEventId = 1,
                Cause = "Nothing to schedule"
            };

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

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


            Assert.Equal(_decisionContext.DecisionType, historyEvent.EventType);
            Assert.Equal(_decisionContext.ActivityId,
                         historyEvent.ScheduleActivityTaskFailedEventAttributes.ActivityId);
            Assert.Equal(_decisionContext.ActivityVersion,
                         historyEvent.ScheduleActivityTaskFailedEventAttributes.ActivityType.Version);
            Assert.Equal(_decisionContext.ActivityName,
                         historyEvent.ScheduleActivityTaskFailedEventAttributes.ActivityType.Name);
            Assert.Equal(_decisionContext.DecisionTaskCompletedEventId,
                         historyEvent.ScheduleActivityTaskFailedEventAttributes.DecisionTaskCompletedEventId);
            Assert.Equal(_decisionContext.Cause,
                         historyEvent.ScheduleActivityTaskFailedEventAttributes.Cause);
        }
Example #5
0
        public void ProcessDecisionContextStartChildWorkflowExecutionInitiatedTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.StartChildWorkflowExecutionInitiated;
            historyEvent.StartChildWorkflowExecutionInitiatedEventAttributes = new StartChildWorkflowExecutionInitiatedEventAttributes
            {
                Input        = "TestInput",
                Control      = "AdditionalData",
                WorkflowType = new WorkflowType
                {
                    Name    = "WorkflowName",
                    Version = "Workflow Version"
                }
            };

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

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


            Assert.Equal(_decisionContext.DecisionType, historyEvent.EventType);
            Assert.Equal(_decisionContext.Control,
                         historyEvent.StartChildWorkflowExecutionInitiatedEventAttributes.Control);
            Assert.Equal(_decisionContext.Input,
                         historyEvent.StartChildWorkflowExecutionInitiatedEventAttributes.Input);
            Assert.Equal(_decisionContext.ChildWorkflowName,
                         historyEvent.StartChildWorkflowExecutionInitiatedEventAttributes.WorkflowType.Name);
            Assert.Equal(_decisionContext.ChildWorkflowVersion,
                         historyEvent.StartChildWorkflowExecutionInitiatedEventAttributes.WorkflowType.Version);
        }
Example #6
0
        public void ProcessDecisionContextActivityTaskScheduledTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.ActivityTaskScheduled;
            historyEvent.ActivityTaskScheduledEventAttributes = new ActivityTaskScheduledEventAttributes
            {
                ActivityType = new ActivityType {
                    Name = "TestActivity", Version = "1.0"
                },
                ActivityId = "TestActivityID",
                Control    = "ImportantData"
            };


            _processor = new SDK.Workflow.WorkflowEventsProcessor(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf);

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

            Assert.Equal(_decisionContext.ActivityId, historyEvent.ActivityTaskScheduledEventAttributes.ActivityId);
            Assert.Equal(_decisionContext.ActivityVersion,
                         historyEvent.ActivityTaskScheduledEventAttributes.ActivityType.Version);
            Assert.Equal(_decisionContext.ActivityName,
                         historyEvent.ActivityTaskScheduledEventAttributes.ActivityType.Name);
            Assert.Equal(_decisionContext.Control, historyEvent.ActivityTaskScheduledEventAttributes.Control);
        }
Example #7
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 #8
0
        public void ProcessDecisionContextMarkerRecordedTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.MarkerRecorded;
            historyEvent.MarkerRecordedEventAttributes = new MarkerRecordedEventAttributes
            {
                MarkerName = "TestMarker"
                , Details  = "MarkerDetails"
            };

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

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

            Assert.Equal(_decisionContext.Markers["TestMarker"], historyEvent.MarkerRecordedEventAttributes.Details);
        }
Example #9
0
        public void ProcessDecisionContextWorkflowExecutionCancelRequestedTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.WorkflowExecutionCancelRequested;
            historyEvent.WorkflowExecutionCancelRequestedEventAttributes = new WorkflowExecutionCancelRequestedEventAttributes
            {
                Cause = "TestCause",
            };

            _processor = new SDK.Workflow.WorkflowEventsProcessor(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf);

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

            Assert.Equal(_decisionContext.DecisionType, historyEvent.EventType);
            Assert.Equal(_decisionContext.Cause, historyEvent.WorkflowExecutionCancelRequestedEventAttributes.Cause);
        }
Example #10
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 #11
0
        public void ProcessDecisionContextWorkflowExecutionContinuedAsNewTest([Frozen] HistoryEvent historyEvent)
        {
            historyEvent.EventType = EventType.WorkflowExecutionContinuedAsNew;
            historyEvent.WorkflowExecutionContinuedAsNewEventAttributes = new WorkflowExecutionContinuedAsNewEventAttributes
            {
                Input = "TestInput",
            };

            _processor = new SDK.Workflow.WorkflowEventsProcessor(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf);

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


            Assert.Equal(_decisionContext.DecisionType, historyEvent.EventType);
            Assert.Equal(_decisionContext.Input, historyEvent.WorkflowExecutionContinuedAsNewEventAttributes.Input);
        }
Example #12
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 #13
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);
        }
Example #14
0
        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);
        }