public void Setup() { _builder = new HistoryEventsBuilder(); _workflow = new Mock <IWorkflow>(); _expectedWorkflowDecision = new Mock <WorkflowDecision>(false, false).Object; _interpretedWorkflowAction = WorkflowAction.Custom(_expectedWorkflowDecision); }
public static void AssertSignalTimedout(this WorkflowDecision decision, ScheduleId scheduleId, long triggerEventId, string[] signalNames, long timeoutTriggerId) { Assert.That(decision, Is.EqualTo(new WorkflowItemSignalsTimedoutDecision(scheduleId, triggerEventId, signalNames, timeoutTriggerId))); var swfDecision = decision.SwfDecision(); var data = swfDecision.RecordMarkerDecisionAttributes.Details.AsDynamic(); Assert.That(data.TimedoutSignalNames.ToObject <string[]>(), Is.EqualTo(signalNames)); Assert.That((long)data.TimeoutTriggerEventId, Is.EqualTo(timeoutTriggerId)); }
public static void AssertRescheduleTimer(this WorkflowDecision decision, ScheduleId scheduleId, TimeSpan timeout) { Assert.That(decision, Is.EqualTo(ScheduleTimerDecision.RescheduleTimer(scheduleId, timeout))); var swfDecision = decision.SwfDecision(); var timerData = swfDecision.StartTimerDecisionAttributes.Control.As <TimerScheduleData>(); Assert.That(timerData.TimerType, Is.EqualTo(TimerType.Reschedule)); Assert.That(swfDecision.StartTimerDecisionAttributes.StartToFireTimeout, Is.EqualTo(timeout.TotalSeconds.ToString())); }
public void Filters_out_propose_to_complete_workflow_decision_when_it_is_generated_along_with_other_decisions() { var decisions = new WorkflowDecision[] { new CompleteWorkflowDecision("complete", true), new ScheduleActivityDecision(Identity.New("something", "1.0").ScheduleId()) }; _workflowEvents.Setup(w => w.NewEvents()).Returns(Events(decisions)); var workflowDecisions = _workflow.Decisions(_workflowEvents.Object); Assert.That(workflowDecisions, Is.EqualTo(new[] { new ScheduleActivityDecision(Identity.New("something", "1.0").ScheduleId()) })); }
public static void AssertSignalTimer(this WorkflowDecision decision, ScheduleId scheduleId, long triggerId, TimeSpan timeout) { Assert.That(decision, Is.EqualTo(ScheduleTimerDecision.SignalTimer(scheduleId, triggerId, timeout))); var swfDecision = decision.SwfDecision(); var timerData = swfDecision.StartTimerDecisionAttributes.Control.As <TimerScheduleData>(); Assert.That(timerData.TimerType, Is.EqualTo(TimerType.SignalTimer)); Assert.That(timerData.SignalTriggerEventId, Is.EqualTo(triggerId)); var startToFireTimeout = TimeSpan.FromSeconds(Double.Parse(swfDecision.StartTimerDecisionAttributes.StartToFireTimeout)); Assert.That((startToFireTimeout - timeout).Duration(), Is.LessThan(TimeSpan.FromSeconds(1))); }
public void Workflow_can_return_custom_decisions_during_completion() { var workflowDecision = new Mock <WorkflowDecision>(false, false); var workflow = new WorkflowToReturnCustomActionOnClosing(workflowDecision.Object); var decisions = new WorkflowDecision[] { new CompleteWorkflowDecision("result2", true) }; _workflowEvents.Setup(w => w.NewEvents()).Returns(Events(decisions.ToArray())); var workflowDecisions = workflow.Decisions(_workflowEvents.Object); Assert.That(workflowDecisions, Is.EqualTo(new[] { workflowDecision.Object })); }
public void Return_complete_workflow_decision_when_it_generated_along_with_a_proposed_complete_workflow_decision() { var decisions = new WorkflowDecision[] { new CompleteWorkflowDecision("result", false), new CompleteWorkflowDecision("result2", true), }; _workflowEvents.Setup(w => w.NewEvents()).Returns(Events(decisions.ToArray())); var workflowDecisions = _workflow.Decisions(_workflowEvents.Object); Assert.That(workflowDecisions, Is.EqualTo(new[] { new CompleteWorkflowDecision("result") })); }
public static void AssertWaitForSignal(this WorkflowDecision decision, ScheduleId scheduleId, long triggerEventId, SignalWaitType waitType, SignalNextAction nextAction, DateTime triggerDateTime, TimeSpan timeout, params string[] signalNames) { Assert.That(decision, Is.EqualTo(new WaitForSignalsDecision(new WaitForSignalData { ScheduleId = scheduleId, TriggerEventId = triggerEventId }))); var swfDecision = decision.SwfDecision(); var data = swfDecision.RecordMarkerDecisionAttributes.Details.AsDynamic(); Assert.That(data.SignalNames.ToObject <string[]>(), Is.EqualTo(signalNames)); Assert.That((SignalWaitType)data.WaitType, Is.EqualTo(waitType)); Assert.That((SignalNextAction)data.NextAction, Is.EqualTo(nextAction)); Assert.That(((DateTime?)data.TriggerEventCompletionDate).Value, Is.EqualTo(triggerDateTime)); Assert.That(((TimeSpan?)data.Timeout).Value, Is.EqualTo(timeout)); }
public void Returns_fail_workflow_decision_when_multiple_close_workflow_decisions_are_generated() { var decisions = new WorkflowDecision[] { new CompleteWorkflowDecision("result", false), new CancelWorkflowDecision("detail"), new CompleteWorkflowDecision("result2", true), new FailWorkflowDecision("reason", "detail"), }; _workflowEvents.Setup(w => w.NewEvents()).Returns(Events(decisions.ToArray())); var workflowDecisions = _workflow.Decisions(_workflowEvents.Object); Assert.That(workflowDecisions, Is.EqualTo(new[] { new FailWorkflowDecision("reason", "detail") })); }
public static void AssertWaitForAllSignals(this WorkflowDecision decision, ScheduleId scheduleId, long triggerEventId, DateTime triggerDateTime, TimeSpan timeout, params string[] signalNames) { decision.AssertWaitForSignal(scheduleId, triggerEventId, SignalWaitType.All, SignalNextAction.Continue, triggerDateTime, timeout, signalNames); }
public JsonResult GetConfigs() { return(JsonWrapper(WorkflowDecision.GetSettings())); }
public WorkflowToReturnCustomActionOnClosing(WorkflowDecision workflowDecision) { _customAction = new Mock <WorkflowAction>(); _customAction.Setup(w => w.GetDecisions()).Returns(new[] { workflowDecision }); }
public TestEvent(WorkflowDecision decision) : base(new HistoryEvent() { EventId = 0, EventTimestamp = DateTime.UtcNow }) { _decision = decision; }