public void Ignore_duplicate_signals()
        {
            var graph = _graphBuilder.LambdaCompletedEventGraph(_promoteId, "input", "result");

            _builder.AddProcessedEvents(graph);
            _builder.AddProcessedEvents(_graphBuilder.WaitForSignalEvent(_promoteId, graph.First().EventId,
                                                                         new[] { "ManagerApproved", "HRApproved" }, SignalWaitType.All));
            var s1 = _graphBuilder.WorkflowSignaledEvent("Managerapproved", "");

            _builder.AddNewEvents(s1);
            var s2 = _graphBuilder.WorkflowSignaledEvent("HRapproved", "");

            _builder.AddNewEvents(s2);
            _builder.AddNewEvents(_graphBuilder.WorkflowSignaledEvent("Managerapproved", ""));
            _builder.AddNewEvents(_graphBuilder.WorkflowSignaledEvent("HRapproved", ""));

            var workflow  = new PromoteWorkflow();
            var decisions = workflow.Decisions(_builder.Result());

            Assert.That(decisions, Is.EqualTo(new WorkflowDecision[]
            {
                new WorkflowItemSignalledDecision(_promoteId, graph.First().EventId, "ManagerApproved", s1.EventId),
                new ScheduleLambdaDecision(Identity.Lambda("EmployeePromoted").ScheduleId(), ""),
                new WorkflowItemSignalledDecision(_promoteId, graph.First().EventId, "HRApproved", s2.EventId),
            }));
        }
        public void Ignore_the_extra_signals_received_received_when_workflow_has_executed_the_wait_for_all_signals_action()
        {
            var graph = _graphBuilder.LambdaCompletedEventGraph(_promoteId, "input", "result");

            _builder.AddNewEvents(graph);
            var s1 = _graphBuilder.WorkflowSignaledEvent("Managerapproved", "");

            _builder.AddNewEvents(s1);
            var s2 = _graphBuilder.WorkflowSignaledEvent("HRapproved", "");

            _builder.AddNewEvents(s2);
            _builder.AddNewEvents(_graphBuilder.WorkflowSignaledEvent("Managerapproved", ""));
            _builder.AddNewEvents(_graphBuilder.WorkflowSignaledEvent("HRapproved", ""));
            var workflow  = new PromoteWorkflow();
            var decisions = workflow.Decisions(_builder.Result());

            Assert.That(decisions, Is.EqualTo(new WorkflowDecision[]
            {
                new WaitForSignalsDecision(new WaitForSignalData()
                {
                    ScheduleId = _promoteId, TriggerEventId = graph.First().EventId
                }),
                new WorkflowItemSignalledDecision(_promoteId, graph.First().EventId, "ManagerApproved", s1.EventId),
                new ScheduleLambdaDecision(Identity.Lambda("EmployeePromoted").ScheduleId(), ""),
                new WorkflowItemSignalledDecision(_promoteId, graph.First().EventId, "HRApproved", s2.EventId),
            }));
        }
        public void Does_not_continue_when_only_one_of_the_signal_is_received()
        {
            var graph = _graphBuilder.LambdaCompletedEventGraph(_promoteId, "input", "result");

            _builder.AddProcessedEvents(graph);
            _builder.AddProcessedEvents(_graphBuilder.WaitForSignalEvent(_promoteId, graph.First().EventId,
                                                                         new[] { "ManagerApproved", "HRApproved" }, SignalWaitType.All));
            var s1 = _graphBuilder.WorkflowSignaledEvent("ManagerApproved", "");

            _builder.AddNewEvents(s1);

            var workflow  = new PromoteWorkflow();
            var decisions = workflow.Decisions(_builder.Result());

            Assert.That(decisions, Is.EqualTo(new []
            {
                new WorkflowItemSignalledDecision(_promoteId, graph.First().EventId, "ManagerApproved", s1.EventId),
            }));
        }
        public void Returns_wait_all_for_signals_decision()
        {
            var graph = _graphBuilder.LambdaCompletedEventGraph(_promoteId, "input", "result");

            _builder.AddNewEvents(graph);
            var workflow  = new PromoteWorkflow();
            var decisions = workflow.Decisions(_builder.Result());

            Assert.That(decisions, Is.EqualTo(new[]
            {
                new WaitForSignalsDecision(new WaitForSignalData()
                {
                    ScheduleId = _promoteId, TriggerEventId = graph.First().EventId
                })
            }));
            var attr = decisions.First().SwfDecision().RecordMarkerDecisionAttributes;
            var data = attr.Details.AsDynamic();

            Assert.That(data.SignalNames.ToObject <string[]>(), Is.EqualTo(new[] { "ManagerApproved", "HRApproved" }));
            Assert.That((SignalWaitType)data.WaitType, Is.EqualTo(SignalWaitType.All));
            Assert.That((SignalNextAction)data.NextAction, Is.EqualTo(SignalNextAction.Continue));
        }