Esempio n. 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();
        }
Esempio n. 2
0
        public async Task ShouldCreateAndGetWorkflows()
        {
            var createdWorkflow = await CreateWorkflow();

            GetWorkflowResponse getWorkflowResponse = await DefaultApi.WorkflowsClient().GetWorkflow(createdWorkflow.Id);

            getWorkflowResponse.ShouldNotBeNull();
            getWorkflowResponse.Id.ShouldNotBeNullOrEmpty();
            getWorkflowResponse.Name.ShouldBe(WorkflowName);
            getWorkflowResponse.Active.ShouldBe(true);

            getWorkflowResponse.Actions.ShouldNotBeNull();
            getWorkflowResponse.Actions.Count.ShouldBe(1);
            getWorkflowResponse.Actions[0].ShouldBeOfType(typeof(WebhookWorkflowActionResponse));
            WebhookWorkflowActionResponse webhookWorkflowActionResponse =
                (WebhookWorkflowActionResponse)getWorkflowResponse.Actions[0];

            webhookWorkflowActionResponse.Headers.ShouldNotBeNull();
            webhookWorkflowActionResponse.Signature.ShouldNotBeNull();
            webhookWorkflowActionResponse.Url.ShouldNotBeNullOrEmpty();
            webhookWorkflowActionResponse.Id.ShouldNotBeNullOrEmpty();

            getWorkflowResponse.Conditions.ShouldNotBeNull();
            getWorkflowResponse.Conditions.Count.ShouldBe(3);
            foreach (WorkflowConditionResponse workflowConditionResponse in getWorkflowResponse.Conditions)
            {
                if (workflowConditionResponse is EntityWorkflowConditionResponse entityCondition)
                {
                    entityCondition.Type.ShouldBe(WorkflowConditionType.Entity);
                    entityCondition.Entities.ShouldNotBeEmpty();
                }
                else if (workflowConditionResponse is EventWorkflowConditionResponse eventCondition)
                {
                    eventCondition.Type.ShouldBe(WorkflowConditionType.Event);
                    eventCondition.Events.ShouldNotBeEmpty();
                }
                else if (workflowConditionResponse is ProcessingChannelWorkflowConditionResponse
                         processingChannelCondition)
                {
                    processingChannelCondition.Type.ShouldBe(WorkflowConditionType.ProcessingChannel);
                    processingChannelCondition.ProcessingChannels.ShouldNotBeEmpty();
                }
                else
                {
                    throw new XunitException("invalid workflow condition response");
                }
            }

            GetWorkflowsResponse getWorkflowsResponse = await DefaultApi.WorkflowsClient().GetWorkflows();

            getWorkflowsResponse.ShouldNotBeNull();
            getWorkflowsResponse.Workflows.ShouldNotBeEmpty();

            foreach (var workflow in getWorkflowsResponse.Workflows)
            {
                workflow.Name.ShouldBe(WorkflowName);
                workflow.Id.ShouldNotBeNullOrEmpty();
                workflow.GetLink("self").ShouldNotBeNull();
                workflow.Active.ShouldBe(true);
            }
        }