Beispiel #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);
        }
Beispiel #2
0
        internal void Activity_GetTypedObjectTest()
        {
            var activity = Substitute.ForPartsOf <ActivityBase <string, TOutput> >("SimpleActivity", "taskList");         // { Version = "1.0" };

            var exptected = new TOutput {
                Value = "correct value"
            };
            var objStr = Utils.SerializeToJSON(exptected);

            var result = activity.GetTypedObject(objStr);

            AssertObjectEquals.PropertyValuesAreEqual(result, exptected);
        }
Beispiel #3
0
        internal void ParallelActivityCollectionBase_GetInputTest()
        {
            var workflow = Substitute.ForPartsOf <ParallelWorkflowCollectionBase <TInput, TOutput> >(_domain, _workflowName, _version, _tasklistName, _amazonSwf);

            var exptected = new TInput {
                Value = "correct value"
            };

            ((IWorkflow)workflow).Input = Utils.SerializeToJSON(exptected);

            var result = workflow.Input;

            AssertObjectEquals.PropertyValuesAreEqual(result, exptected);
        }
Beispiel #4
0
        internal void ParallelCollectionItem_GetInputTest()
        {
            var item = Substitute.ForPartsOf <ParallelCollectionItem <TInput> >();

            var exptected = new TInput {
                Value = "correct value"
            };

            ((ICollectionItemInput)item).Input = Utils.SerializeToJSON(exptected);

            var result = item.Input;

            AssertObjectEquals.PropertyValuesAreEqual(result, exptected);
        }
Beispiel #5
0
        internal void ParallelActivityCollectionBase_GetInputTest()
        {
            var activity = Substitute.ForPartsOf <ParallelActivityCollectionBase <TInput, string, string, string> >("ActivityName", "TaskList");

            var exptected = new TInput {
                Value = "correct value"
            };

            ((IActivity)activity).Input = Utils.SerializeToJSON(exptected);

            var result = activity.Input;

            AssertObjectEquals.PropertyValuesAreEqual(result, exptected);
        }
Beispiel #6
0
        internal void Activity_GetInputTest()
        {
            var activity = Substitute.ForPartsOf <ActivityBase <TOutput, TOutput> >("SimpleActivity", "taskList");         // { Version = "1.0" };

            var exptected = new TOutput {
                Value = "correct value"
            };

            ((IActivity)activity).Input = Utils.SerializeToJSON(exptected);

            var result = activity.Input;

            AssertObjectEquals.PropertyValuesAreEqual(result, exptected);
        }
        public void MakeDecision_WorkflowExecutionStartedTest([Frozen] IDecider decider,
                                                              [Frozen] RespondDecisionTaskCompletedRequest respondDecisionTask)
        {
            _processor = new SDK.Workflow.WorkflowEventsProcessor(_decisionTask, _workflowBase, _pollforDecisionTaskRequest, _amazonSwf);

            var decisionContext = new WorkflowDecisionContext()
            {
                DecisionType = EventType.WorkflowExecutionStarted
            };

            decider.OnWorkflowExecutionStarted(decisionContext).Returns(info => respondDecisionTask);

            _decisionCompletedRequest = _processor.MakeDecision(decider, decisionContext);
            AssertObjectEquals.PropertyValuesAreEqual(_decisionCompletedRequest.Decisions.First(), respondDecisionTask.Decisions.First());
        }
        public void ResultObject_WithoutStoreTest()
        {
            var expectedValue = "Expected Value";

            var context = Substitute.For <WorkflowDecisionContext>();

            var result     = new StepResult <string>(expectedValue, true);
            var resultSerd = Utils.SerializeToJSON(result);

            context.ResultRef = resultSerd;

            AssertObjectEquals.PropertyValuesAreEqual(context.ResultObject, result);

            Assert.Equal(expectedValue, context.ResultData);
        }
        public void ResultObject_WithStoreTest()
        {
            var expectedValue = "Expected Value";
            var storageKey    = "validStoreKey";

            var result     = new StepResult <string>(expectedValue, true);
            var resultSerd = Utils.SerializeToJSON(result);

            var storeManager = Substitute.For <IStorageManager>();

            storeManager.GetData(Arg.Any <S3StorageReference>()).Returns(info => resultSerd);

            var context = Substitute.For <WorkflowDecisionContext>(storeManager);

            context.ResultRef = storageKey;

            AssertObjectEquals.PropertyValuesAreEqual(context.ResultObject, result);
            Assert.Equal(expectedValue, context.ResultData);

            // Checking if the GetSerializedObjectFromStore method was called with exact parameter.
            storeManager.Received().GetData(Arg.Is <S3StorageReference>(x => x.StorageKey == storageKey));
        }
Beispiel #10
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);
        }