Ejemplo n.º 1
0
        public void Calling_process_action_with_a_process_rule_response_request_for_an_in_flight_contract_with_no_triggered_actions_should_progress_the_trade_to_approved()
        {
            var processor          = GetProcessor(true);
            var currentContract    = new Contract();
            var contractRequest    = ProcessContractRequest.New(currentContract);
            var trackingRefernence = contractRequest.Payload.TrackingReference;

            var processResponse = processor.ProcessAction(contractRequest).Result;

            AwaitAssert(() => {
                Assert.IsNotNull(_contractPersistence.GetContractTrackingReference(trackingRefernence));
                Assert.IsTrue(_responseObserver.Responses.Any(r => (r.Request as IActionRequest)?.Context.OriginatingRequest == contractRequest && r.GetStateChange().NewState.CurrentState == "IsPendingApproval"));
            },
                        assertTimeout, assertInterval);

            var ruleResponse = new RuleResponse {
                TriggeredActions = new List <TriggeredAction>()
            };
            var ruleRequest = ProcessRuleResponseRequest.New(currentContract, ruleResponse, trackingRefernence);

            processResponse = processor.ProcessAction(ruleRequest).Result;

            AwaitAssert(() => {
                Assert.IsTrue(_responseObserver.Responses.Any(r => (r.Request as IActionRequest)?.Context.OriginatingRequest == contractRequest && r.GetStateChange().NewState.CurrentState == "IsNotPendingResubmit"));
            },
                        assertTimeout, assertInterval);
        }
Ejemplo n.º 2
0
        public void Calling_process_action_with_a_process_workflow_response_request_for_an_in_flight_contract_with_triggered_actions_should_leave_the_contract_pending_approval_unless_all_actions_are_approved()
        {
            var processor          = GetProcessor(true);
            var currentContract    = new Contract();
            var contractRequest    = ProcessContractRequest.New(currentContract);
            var trackingRefernence = contractRequest.Payload.TrackingReference;

            var processResponse = processor.ProcessAction(contractRequest).Result;

            AwaitAssert(() => {
                Assert.IsNotNull(_contractPersistence.GetContractTrackingReference(trackingRefernence));
                Assert.IsTrue(_responseObserver.Responses.Any(r => (r.Request as IActionRequest)?.Context.OriginatingRequest == contractRequest && r.GetStateChange().NewState.CurrentState == "IsPendingApproval"));
            },
                        assertTimeout, assertInterval);

            var ruleResponse = new RuleResponse
            {
                TriggeredActions = new List <TriggeredAction>()
                {
                    new TriggeredAction {
                        ActionReference = Guid.NewGuid()
                    },
                    new TriggeredAction {
                        ActionReference = Guid.NewGuid()
                    }
                }
            };
            var ruleRequest = ProcessRuleResponseRequest.New(currentContract, ruleResponse, trackingRefernence);

            processResponse = processor.ProcessAction(ruleRequest).Result;

            AwaitAssert(() => {
                Assert.IsTrue(_responseObserver.Responses.Any(r => (r.Request as IActionRequest)?.Context.OriginatingRequest == ruleRequest && r.GetStateChange().NewState.CurrentState == "IsPendingApproval"));
            },
                        assertTimeout, assertInterval);

            var workflowResponse = new WorkflowResponse
            {
                ActionReference = ruleResponse.TriggeredActions.First().ActionReference,
                ActionState     = Domain.ActionState.Approved
            };
            var workflowRequest = ProcessWorkflowResponseRequest.New(currentContract, workflowResponse, trackingRefernence);

            processResponse = processor.ProcessAction(workflowRequest).Result;
        }