示例#1
0
        public async Task ShouldGetWorkflows()
        {
            GetWorkflowsResponse getWorkflowResponse = new GetWorkflowsResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Get <GetWorkflowsResponse>("workflows", _authorization, CancellationToken.None))
            .ReturnsAsync(() => getWorkflowResponse);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var response = await workflowsClient.GetWorkflows();

            response.ShouldNotBeNull();
        }
示例#2
0
        public async Task ShouldRemoveWorkflow()
        {
            var response = new EmptyResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Delete <EmptyResponse>("workflows" + "/workflow_id", _authorization, CancellationToken.None))
            .ReturnsAsync(() => response);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var getResponse = await workflowsClient.RemoveWorkflow("workflow_id");

            getResponse.ShouldNotBeNull();
        }
示例#3
0
        public async Task ShouldGetActionInvocations()
        {
            WorkflowActionInvocationsResponse response = new WorkflowActionInvocationsResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Get <WorkflowActionInvocationsResponse>("workflows/events/eventId/actions/actionId",
                                                                               _authorization, CancellationToken.None))
            .ReturnsAsync(() => response);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var getResponse = await workflowsClient.GetActionInvocations("eventId", "actionId");

            getResponse.ShouldNotBeNull();
        }
示例#4
0
        public async Task ShouldReflowByEventAndWorkflow()
        {
            ReflowResponse response = new ReflowResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Post <ReflowResponse>("workflows/events/event_id/workflow/workflow_id/reflow",
                                                             _authorization, null, CancellationToken.None, null))
            .ReturnsAsync(() => response);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var getResponse = await workflowsClient.ReflowByEventAndWorkflow("event_id", "workflow_id");

            getResponse.ShouldNotBeNull();
        }
示例#5
0
        public async Task ShouldGetSubjectEvents()
        {
            SubjectEventsResponse subjectEventsResponse = new SubjectEventsResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Get <SubjectEventsResponse>("workflows" + "/events/subject/subject_id", _authorization,
                                                                   CancellationToken.None))
            .ReturnsAsync(() => subjectEventsResponse);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var response = await workflowsClient.GetSubjectEvents("subject_id");

            response.ShouldNotBeNull();
        }
示例#6
0
        public async Task ShouldGetEventTypes()
        {
            ItemsResponse <EventTypesResponse> response = new ItemsResponse <EventTypesResponse>();

            _apiClient.Setup(apiClient =>
                             apiClient.Get <ItemsResponse <EventTypesResponse> >("workflows" + "/event-types", _authorization,
                                                                                 CancellationToken.None))
            .ReturnsAsync(() => response);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var getResponse = await workflowsClient.GetEventTypes();

            getResponse.ShouldNotBeNull();
        }
示例#7
0
        public async Task ShouldFailReflow_InvalidParams()
        {
            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            try
            {
                await workflowsClient.Reflow(null);

                throw new XunitException();
            }
            catch (Exception ex)
            {
                ex.ShouldBeOfType(typeof(CheckoutArgumentException));
                ex.Message.ShouldBe("reflowRequest cannot be null");
            }
        }
示例#8
0
        public async Task ShouldFailGetSubjectEvents_InvalidParams()
        {
            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            try
            {
                await workflowsClient.GetSubjectEvents("  ");

                throw new XunitException();
            }
            catch (Exception ex)
            {
                ex.ShouldBeOfType(typeof(CheckoutArgumentException));
                ex.Message.ShouldBe("subjectId cannot be blank");
            }
        }
示例#9
0
        public async Task ShouldCreateWorkflow()
        {
            CreateWorkflowRequest  createWorkflowRequest  = new CreateWorkflowRequest();
            CreateWorkflowResponse createWorkflowResponse = new CreateWorkflowResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Post <CreateWorkflowResponse>("workflows", _authorization,
                                                                     createWorkflowRequest, CancellationToken.None, null))
            .ReturnsAsync(() => createWorkflowResponse);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var response = await workflowsClient.CreateWorkflow(createWorkflowRequest);

            response.ShouldNotBeNull();
        }
示例#10
0
        public async Task ShouldUpdateWorkflowAction()
        {
            WebhookWorkflowActionRequest workflowActionRequest = new WebhookWorkflowActionRequest();

            _apiClient.Setup(apiClient =>
                             apiClient.Put <EmptyResponse>("workflows" + "/workflow_id/actions/action_id", _authorization,
                                                           workflowActionRequest, CancellationToken.None, null))
            .ReturnsAsync(() => new EmptyResponse());

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var getResponse =
                await workflowsClient.UpdateWorkflowAction("workflow_id", "action_id", workflowActionRequest);

            getResponse.ShouldNotBeNull();
        }
示例#11
0
        public async Task ShouldUpdateWorkflow()
        {
            UpdateWorkflowRequest  updateWorkflowRequest  = new UpdateWorkflowRequest();
            UpdateWorkflowResponse updateWorkflowResponse = new UpdateWorkflowResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Patch <UpdateWorkflowResponse>("workflows" + "/workflow_id", _authorization,
                                                                      updateWorkflowRequest, CancellationToken.None, null))
            .ReturnsAsync(() => updateWorkflowResponse);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var response = await workflowsClient.UpdateWorkflow("workflow_id", updateWorkflowRequest);

            response.ShouldNotBeNull();
        }
示例#12
0
        public async Task ShouldUpdateWorkflowCondition()
        {
            EventWorkflowConditionRequest eventWorkflowConditionRequest = new EventWorkflowConditionRequest();

            _apiClient.Setup(apiClient =>
                             apiClient.Put <EmptyResponse>("workflows" + "/workflow_id/conditions/condition_id", _authorization,
                                                           eventWorkflowConditionRequest, CancellationToken.None, null))
            .ReturnsAsync(() => new EmptyResponse());

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var updateResponse =
                await workflowsClient.UpdateWorkflowCondition("workflow_id", "condition_id",
                                                              eventWorkflowConditionRequest);

            updateResponse.ShouldNotBeNull();
        }
示例#13
0
        public async Task ShouldReflow()
        {
            ReflowBySubjectsRequest reflowBySubjectsRequest =
                new ReflowBySubjectsRequest {
                Subjects = new List <string>(), Workflows = new List <string>()
            };
            ReflowResponse response = new ReflowResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Post <ReflowResponse>("workflows/events/reflow", _authorization, reflowBySubjectsRequest,
                                                             CancellationToken.None, null))
            .ReturnsAsync(() => response);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var getResponse = await workflowsClient.Reflow(reflowBySubjectsRequest);

            getResponse.ShouldNotBeNull();
        }
示例#14
0
        public async Task ShouldFailUpdateWorkflowCondition_InvalidParams()
        {
            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            try
            {
                await workflowsClient.UpdateWorkflowCondition("", "condition_id",
                                                              new EventWorkflowConditionRequest());

                throw new XunitException();
            }
            catch (Exception ex)
            {
                ex.ShouldBeOfType(typeof(CheckoutArgumentException));
                ex.Message.ShouldBe("workflowId cannot be blank");
            }

            try
            {
                await workflowsClient.UpdateWorkflowCondition("12345", "", new EventWorkflowConditionRequest());

                throw new XunitException();
            }
            catch (Exception ex)
            {
                ex.ShouldBeOfType(typeof(CheckoutArgumentException));
                ex.Message.ShouldBe("conditionId cannot be blank");
            }

            try
            {
                await workflowsClient.UpdateWorkflowCondition("12345", "46562", null);

                throw new XunitException();
            }
            catch (Exception ex)
            {
                ex.ShouldBeOfType(typeof(CheckoutArgumentException));
                ex.Message.ShouldBe("workflowConditionRequest cannot be null");
            }
        }
示例#15
0
        public async Task ShouldFailGetWorkflowById_InvalidParams()
        {
            GetWorkflowResponse getWorkflowResponse = new GetWorkflowResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Get <GetWorkflowResponse>("workflows" + "/workflow_id", _authorization,
                                                                 CancellationToken.None))
            .ReturnsAsync(() => getWorkflowResponse);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            try
            {
                await workflowsClient.GetWorkflow(null);

                throw new XunitException();
            }
            catch (Exception ex)
            {
                ex.ShouldBeOfType(typeof(CheckoutArgumentException));
                ex.Message.ShouldBe("workflowId cannot be null");
            }
        }
示例#16
0
        public async Task ShouldFailCreateWorkflow_InvalidParams()
        {
            CreateWorkflowRequest  createWorkflowRequest  = new CreateWorkflowRequest();
            CreateWorkflowResponse createWorkflowResponse = new CreateWorkflowResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Post <CreateWorkflowResponse>("workflows", _authorization,
                                                                     createWorkflowRequest, CancellationToken.None, null))
            .ReturnsAsync(() => createWorkflowResponse);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            try
            {
                await workflowsClient.CreateWorkflow(null);

                throw new XunitException();
            }
            catch (Exception ex)
            {
                ex.ShouldBeOfType(typeof(CheckoutArgumentException));
                ex.Message.ShouldBe("createWorkflowRequest cannot be null");
            }
        }