public void Can_override_scheduling_properties_when_workflow_description_is_not_provided() { var item = new ChildWorkflowItem(_identity, _workflow.Object); item.WithChildPolicy(_ => "newchild").WithLambdaRole(_ => "newlambda").OnTaskList(_ => "newtask") .WithPriority(_ => 2).WithTimeouts(_ => new WorkflowTimeouts() { ExecutionStartToCloseTimeout = TimeSpan.FromSeconds(4), TaskStartToCloseTimeout = TimeSpan.FromSeconds(5) }).WithTags(_ => new[] { "hello", "hi" }); var swfDecision = item.ScheduleDecisions().First().SwfDecision(); Assert.That(swfDecision.DecisionType, Is.EqualTo(DecisionType.StartChildWorkflowExecution)); var attr = swfDecision.StartChildWorkflowExecutionDecisionAttributes; Assert.That(attr.WorkflowType.Name, Is.EqualTo(WorkflowName)); Assert.That(attr.WorkflowType.Version, Is.EqualTo(Version)); Assert.That(attr.WorkflowId, Is.EqualTo(_scheduleIdentity.ToString())); Assert.That(attr.Control.As <ScheduleData>().PN, Is.EqualTo(_identity.PositionalName)); Assert.That(attr.ChildPolicy.Value, Is.EqualTo("newchild")); Assert.That(attr.ExecutionStartToCloseTimeout, Is.EqualTo("4")); Assert.That(attr.LambdaRole, Is.EqualTo("newlambda")); Assert.That(attr.TaskList.Name, Is.EqualTo("newtask")); Assert.That(attr.TaskPriority, Is.EqualTo("2")); Assert.That(attr.TaskStartToCloseTimeout, Is.EqualTo("5")); Assert.That(attr.TagList, Is.EqualTo(new[] { "hello", "hi" })); }
public void Schedule_the_child_workflow() { var description = new WorkflowDescription("1.0") { DefaultChildPolicy = "child", DefaultExecutionStartToCloseTimeout = TimeSpan.FromSeconds(3), DefaultLambdaRole = "lambdarole", DefaultTaskListName = "task", DefaultTaskPriority = 1, DefaultTaskStartToCloseTimeout = TimeSpan.FromSeconds(1), }; var item = new ChildWorkflowItem(_identity, _workflow.Object, description); var swfDecision = item.ScheduleDecisions().First().SwfDecision(); Assert.That(swfDecision.DecisionType, Is.EqualTo(DecisionType.StartChildWorkflowExecution)); var attr = swfDecision.StartChildWorkflowExecutionDecisionAttributes; Assert.That(attr.WorkflowType.Name, Is.EqualTo(WorkflowName)); Assert.That(attr.WorkflowType.Version, Is.EqualTo(Version)); Assert.That(attr.WorkflowId, Is.EqualTo(_scheduleIdentity.ToString())); Assert.That(attr.Control.As <ScheduleData>().PN, Is.EqualTo(_identity.PositionalName)); Assert.That(attr.ChildPolicy.Value, Is.EqualTo("child")); Assert.That(attr.ExecutionStartToCloseTimeout, Is.EqualTo("3")); Assert.That(attr.LambdaRole, Is.EqualTo("lambdarole")); Assert.That(attr.TaskList.Name, Is.EqualTo("task")); Assert.That(attr.TaskPriority, Is.EqualTo("1")); Assert.That(attr.TaskStartToCloseTimeout, Is.EqualTo("1")); Assert.That(attr.TagList, Is.Empty); }
public void Invalid_arguments() { var childWorkflowItem = new ChildWorkflowItem(_identity, _workflow.Object); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.OnCompletion(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.OnFailure(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.OnCancelled(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.OnTerminated(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.OnTimedout(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.OnStartFailed(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.WithInput(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.WithChildPolicy(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.WithLambdaRole(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.OnTaskList(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.WithPriority(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.WithTimeouts(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.WithTags(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.When(null)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.When(null, _ => WorkflowAction.Empty)); Assert.Throws <ArgumentNullException>(() => childWorkflowItem.When(_ => true, null)); Assert.Throws <ArgumentException>(() => childWorkflowItem.AfterTimer(null)); Assert.Throws <ArgumentException>(() => childWorkflowItem.AfterActivity(null, "v")); Assert.Throws <ArgumentException>(() => childWorkflowItem.AfterActivity("n", null)); Assert.Throws <ArgumentException>(() => childWorkflowItem.AfterLambda(null)); Assert.Throws <ArgumentException>(() => childWorkflowItem.AfterChildWorkflow(null, "1.0")); Assert.Throws <ArgumentException>(() => childWorkflowItem.AfterChildWorkflow("n", null)); }
public void Reschedule_decision_is_timer_schedule_decision_for_child_workflow_item() { var item = new ChildWorkflowItem(_identity, _workflow.Object); var decisions = item.RescheduleDecisions(TimeSpan.FromSeconds(20)).ToArray(); Assert.That(decisions.Length, Is.EqualTo(1)); decisions[0].AssertRescheduleTimer(_scheduleIdentity, TimeSpan.FromSeconds(20)); }
public void By_default_schedule_with_workflow_input() { var item = new ChildWorkflowItem(_identity, _workflow.Object); var decisions = item.ScheduleDecisions(); var swfDecision = decisions.Single().SwfDecision(); Assert.That(swfDecision.StartChildWorkflowExecutionDecisionAttributes.Input, Is.EqualTo("input")); }
public void Returns_cancel_child_workflow_decision_for_child_workflow_item_when_neither_child_workflow_not_reschedule_timer_are_active() { var identity = Identity.New("workflow", "ver"); var item = new ChildWorkflowItem(identity, _workflow.Object); var workflowAction = WorkflowAction.Cancel(item); var decisions = workflowAction.Decisions(Mock.Of <IWorkflow>()); Assert.That(decisions, Is.EqualTo(new[] { new CancelRequestWorkflowDecision(identity.ScheduleId(), null) })); }
public void Returns_cancel_timer_decision_for_child_workflow_item_when_reschedule_timer_is_active() { var identity = Identity.New("workflow", "ver"); SetupWorkflowToReturns(_eventGraph.TimerStartedGraph(identity.ScheduleId(), TimeSpan.FromSeconds(2), true)); var item = new ChildWorkflowItem(identity, _workflow.Object); var workflowAction = WorkflowAction.Cancel(item); var decisions = workflowAction.Decisions(Mock.Of <IWorkflow>()); Assert.That(decisions, Is.EqualTo(new[] { new CancelTimerDecision(identity.ScheduleId()) })); }
public void Returns_cancel_child_workflow_decision_for_child_workflow_item_when_reschedule_timer_is_not_active() { var identity = Identity.New("workflow", "ver"); SetupWorkflowToReturns(_eventGraph.ChildWorkflowStartedEventGraph(identity.ScheduleId(), "id", "input")); var childWorkflowItem = new ChildWorkflowItem(identity, _workflow.Object); var workflowAction = WorkflowAction.Cancel(childWorkflowItem); var decisions = workflowAction.Decisions(Mock.Of <IWorkflow>()); Assert.That(decisions, Is.EqualTo(new[] { new CancelRequestWorkflowDecision(identity.ScheduleId(), "id") })); }
public void Input_can_be_customized() { var workflow = new Mock <IWorkflow>(); const string workflowInput = "\"input\""; workflow.SetupGet(w => w.WorkflowHistoryEvents).Returns(new WorkflowHistoryEvents(_eventGraphBuilder.WorkflowStartedGraph(workflowInput))); var item = new ChildWorkflowItem(_identity, workflow.Object); item.WithInput(_ => new{ Id = 1 }); var decisions = item.ScheduleDecisions(); var swfDecision = decisions.Single().SwfDecision(); Assert.That(swfDecision.StartChildWorkflowExecutionDecisionAttributes.Input, Is.EqualTo("{\"Id\":1}")); }
public void Schedule_the_child_workflow_without_providing_workflow_description() { var item = new ChildWorkflowItem(_identity, _workflow.Object); var swfDecision = item.ScheduleDecisions().First().SwfDecision(); Assert.That(swfDecision.DecisionType, Is.EqualTo(DecisionType.StartChildWorkflowExecution)); var attr = swfDecision.StartChildWorkflowExecutionDecisionAttributes; Assert.That(attr.WorkflowType.Name, Is.EqualTo(WorkflowName)); Assert.That(attr.WorkflowType.Version, Is.EqualTo(Version)); Assert.That(attr.WorkflowId, Is.EqualTo(_scheduleIdentity.ToString())); Assert.That(attr.Control.As <ScheduleData>().PN, Is.EqualTo(_identity.PositionalName)); Assert.That(attr.ChildPolicy, Is.Null); Assert.That(attr.ExecutionStartToCloseTimeout, Is.Null); Assert.That(attr.LambdaRole, Is.Null); Assert.That(attr.TaskList, Is.Null); Assert.That(attr.TaskPriority, Is.Null); Assert.That(attr.TaskStartToCloseTimeout, Is.Null); Assert.That(attr.TagList, Is.Empty); }