Example #1
0
        private ActivityItem CreateActivityItemWith(IEnumerable <HistoryEvent> eventGraph)
        {
            var workflowHistoryEvents = new WorkflowHistoryEvents(eventGraph);

            _workflow.SetupGet(w => w.WorkflowHistoryEvents).Returns(workflowHistoryEvents);
            return(new ActivityItem(_activityIdentity, _workflow.Object));
        }
        public void Should_be_active_when_activity_is_just_started()
        {
            var activityStartedEventGraph = _builder.ActivityStartedGraph(Identity.New("activity", "1.0"), "id");
            var workflowHistoryEvents     = new WorkflowHistoryEvents(activityStartedEventGraph);

            Assert.IsTrue(workflowHistoryEvents.HasActiveEvent());
        }
Example #3
0
        public void Should_not_be_active_when_activity_is_completed()
        {
            var activityCompletedEventGraph = _builder.ActivityCompletedGraph(Identity.New(ActivityName, ActivityVersion).ScheduleId(), "id", "res");
            var workflowHistoryEvents       = new WorkflowHistoryEvents(activityCompletedEventGraph);

            Assert.IsFalse(workflowHistoryEvents.HasActiveEvent());
        }
Example #4
0
        public void Should_be_active_when_activity_cancellation_is_in_progress()
        {
            var activityCancelRequestedGraph = _builder.ActivityCancelRequestedGraph(Identity.New(ActivityName, ActivityVersion).ScheduleId(), "id");
            var workflowHistoryEvents        = new WorkflowHistoryEvents(activityCancelRequestedGraph);

            Assert.IsTrue(workflowHistoryEvents.HasActiveEvent());
        }
Example #5
0
        public void Latest_event_id()
        {
            var events = _builder.TimerFiredGraph(Identity.Timer("id").ScheduleId(), TimeSpan.FromSeconds(2));
            var workflowHistoryEvents = new WorkflowHistoryEvents(events);

            Assert.That(workflowHistoryEvents.LatestEventId, Is.EqualTo(events.First().EventId));
        }
Example #6
0
        public void Should_not_be_active_when_timer_is_fired()
        {
            var timerStartedEventGraph = _builder.TimerFiredGraph(Identity.Timer("id").ScheduleId(), TimeSpan.FromSeconds(2));
            var workflowHistoryEvents  = new WorkflowHistoryEvents(timerStartedEventGraph);

            Assert.IsFalse(workflowHistoryEvents.HasActiveEvent());
        }
Example #7
0
        public void Should_be_active_when_activity_is_just_scheduled()
        {
            var activityScheduledEventGraph = _builder.ActivityScheduledGraph(Identity.New(ActivityName, ActivityVersion).ScheduleId());
            var workflowHistoryEvents       = new WorkflowHistoryEvents(activityScheduledEventGraph);

            Assert.IsTrue(workflowHistoryEvents.HasActiveEvent());
        }
Example #8
0
        public void Workflow_cancellation_failed_event_is_interpreted()
        {
            var eventGraph = _builder.WorkflowCancellationFailedEvent("cause");
            var events     = new WorkflowHistoryEvents(new[] { eventGraph });
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new WorkflowCancellationFailedEvent(eventGraph) }));
        }
Example #9
0
        public void Non_interpretable_events_are_filtered_out()
        {
            var eventGraph = NotInterpretingEventGraph();
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.Empty);
        }
Example #10
0
        public void Child_workflow_start_failed_event_is_interpreted()
        {
            var eventGraph = _builder.ChildWorkflowStartFailedEventGraph(_childWorkflow.ScheduleId(), "rid", "i");
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new ChildWorkflowStartFailedEvent(eventGraph.First(), eventGraph) }));
        }
Example #11
0
        public void Lambda_function_start_failed_event_is_interpreted()
        {
            var eventGraph = _builder.LambdaStartFailedEventGraph(Identity.Lambda("l").ScheduleId(), "input", "reason", "details");
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new LambdaStartFailedEvent(eventGraph.First(), eventGraph) }));
        }
Example #12
0
        public void Lambda_function_scheduling_failed_event_is_interpreted()
        {
            var eventGraph = new [] { _builder.LambdaSchedulingFailedEventGraph(Identity.Lambda("l").ScheduleId(), "reason") };
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new LambdaSchedulingFailedEvent(eventGraph.First()) }));
        }
Example #13
0
        public void Should_be_active_when_activity_is_just_started_after_failure()
        {
            var eventGraph = _builder.ActivityStartedGraph(Identity.New(ActivityName, ActivityVersion).ScheduleId(), "id")
                             .Concat(_builder.ActivityFailedGraph(Identity.New(ActivityName, ActivityVersion).ScheduleId(), "id", "res", "detail"));
            var workflowHistoryEvents = new WorkflowHistoryEvents(eventGraph);

            Assert.IsTrue(workflowHistoryEvents.HasActiveEvent());
        }
Example #14
0
        public void External_workflow_cancel_request_failed_event_is_interpreted()
        {
            var eventGraph = _builder.ExternalWorkflowCancelRequestFailedEvent(Identity.New("w", "v").ScheduleId(), "rid", "cause");
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new ExternalWorkflowCancelRequestFailedEvent(eventGraph.First()) }));
        }
Example #15
0
        public void Workflow_cancellation_requested_event_is_interpreted()
        {
            var eventGraph = WorkflowCancellationRequestedEventGraph();
            var events     = new WorkflowHistoryEvents(new[] { eventGraph });
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new WorkflowCancellationRequestedEvent(eventGraph) }));
        }
Example #16
0
        public void Workflow_signaled_failed_event_is_interpreted()
        {
            var eventGraph = _builder.WorkflowSignalFailedEvent("cause", "wid", "rid");
            var events     = new WorkflowHistoryEvents(new[] { eventGraph });
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new WorkflowSignalFailedEvent(eventGraph) }));
        }
Example #17
0
        public void Workflow_signaled_event_is_interpreted()
        {
            var eventGraph = WorkflowSignaledEventGraph();
            var events     = new WorkflowHistoryEvents(new [] { eventGraph });
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new WorkflowSignaledEvent(eventGraph) }));
        }
Example #18
0
        public void Should_be_active_when_activity_is_started_but_its_cancel_request_failed()
        {
            var eventGraph = _builder.ActivityCancellationFailedGraph(Identity.New(ActivityName, ActivityVersion).ScheduleId(), "reason")
                             .Concat(_builder.ActivityFailedGraph(Identity.New(ActivityName, ActivityVersion).ScheduleId(), "id", "res", "detail"));
            var workflowHistoryEvents = new WorkflowHistoryEvents(eventGraph);

            Assert.IsTrue(workflowHistoryEvents.HasActiveEvent());
        }
Example #19
0
        public void Lambda_function_timedout_event_is_interpreted()
        {
            var eventGraph = _builder.LamdbaTimedoutEventGraph(Identity.Lambda("l").ScheduleId(), "input", "reason").ToArray();
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new LambdaTimedoutEvent(eventGraph.First(), eventGraph) }));
        }
        public void Jumping_out_to_different_parent_branch_is_not_allowed()
        {
            var siblingActivity = CompletedActivityGraph(SiblingActivityName);
            var workflow        = new WorkflowToJumpToDifferentBranch();
            var historyEvents   = new WorkflowHistoryEvents(siblingActivity, siblingActivity.Last().EventId, siblingActivity.First().EventId);

            Assert.Throws <OutOfBranchJumpException>(() => workflow.NewExecutionFor(historyEvents).Execute());
        }
Example #21
0
        public void Timer_fired_event_is_interpreted()
        {
            var eventGraph = TimerFiredEventGraph();
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new TimerFiredEvent(eventGraph.First(), eventGraph) }));
        }
Example #22
0
        private TimerItem CreateTimerItemFor(IEnumerable <HistoryEvent> eventGraph)
        {
            var workflowHistoryEvents = new WorkflowHistoryEvents(eventGraph);
            var workflow = new Mock <IWorkflow>();

            workflow.SetupGet(w => w.WorkflowHistoryEvents).Returns(workflowHistoryEvents);
            return(TimerItem.New(_timerIdentity, workflow.Object));
        }
Example #23
0
        public void Activity_cancellation_failed_event_is_interpreted()
        {
            var eventGraph = ActivityCancellationFailedEventGraph();
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new ActivityCancellationFailedEvent(eventGraph.First()) }));
        }
Example #24
0
        public void Workflow_started_event_is_interpreted()
        {
            var eventGraph = WorkflowStartedEventGraph();
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new WorkflowStartedEvent(eventGraph.First()) }));
        }
Example #25
0
        public void Activity_timedout_event_is_interpreted()
        {
            var eventGraph = ActivityTimedoutEventGraph();
            var events     = new WorkflowHistoryEvents(eventGraph);
            var newEvents  = events.NewEvents();

            Assert.That(newEvents, Is.EqualTo(new[] { new ActivityTimedoutEvent(eventGraph.First(), eventGraph) }));
        }
Example #26
0
        public void Should_be_active_when_lambda_is_started()
        {
            var eventGraph = _builder.LambdaStartedEventGraph(Identity.Lambda(LambdaName).ScheduleId(), "input");

            var workflowHistoryEvents = new WorkflowHistoryEvents(eventGraph);

            Assert.IsTrue(workflowHistoryEvents.HasActiveEvent());
        }
        public void No_workflow_item_is_scheduled_when_its_startup_activity_and_timer_are_not_scheduled()
        {
            var startedEvent  = _builder.WorkflowStartedEvent();
            var workflow      = new WorkflowWithNotSchedulableStartupActivityAndTimer();
            var historyEvents = new WorkflowHistoryEvents(new[] { startedEvent });
            var decisions     = workflow.NewExecutionFor(historyEvents).Execute();

            Assert.That(decisions, Is.Empty);
        }
        public void Can_interpret_workflow_cancellation_failed_failed_event()
        {
            _workflow.Setup(w => w.OnWorkflowCancellationFailed(It.IsAny <WorkflowCancellationFailedEvent>())).Returns(_interpretedWorkflowAction);
            var historyEvents = new WorkflowHistoryEvents(new[] { _builder.WorkflowCancellationFailedEvent("cause") });

            var workflowDecisions = historyEvents.InterpretNewEventsFor(_workflow.Object);

            Assert.That(workflowDecisions, Is.EqualTo(new[] { _expectedWorkflowDecision }));
        }
Example #29
0
        public void Should_be_active_when_child_workflow_is_started_and_its_cancellation_is_requested()
        {
            var eventGraph = _builder.ChildWorkflowCancellationRequestedEventGraph(Identity.New(WorkflowName, WorkflowVersion).ScheduleId(),
                                                                                   "rid", "input");

            var workflowHistoryEvents = new WorkflowHistoryEvents(eventGraph);

            Assert.IsTrue(workflowHistoryEvents.HasActiveEvent());
        }
Example #30
0
        public void Should_not_be_active_when_child_workflow_is_completed()
        {
            var eventGraph = _builder.ChildWorkflowCompletedGraph(Identity.New(WorkflowName, WorkflowVersion).ScheduleId(),
                                                                  "rid", "input", "detail");

            var workflowHistoryEvents = new WorkflowHistoryEvents(eventGraph);

            Assert.IsFalse(workflowHistoryEvents.HasActiveEvent());
        }