Exemple #1
0
 public void GivenTheExternalServiceResponseWillSpecifyContextItemsToUpsert(Table table)
 {
     ExternalServiceBindings.ExternalService service = ExternalServiceBindings.GetService(this.scenarioContext);
     service.ActionResponseBody ??= new ExternalServiceWorkflowResponse();
     service.ActionResponseBody.ContextValuesToSetOrAdd = table.Rows.ToDictionary(
         row => row["Key"],
         row => row["Value"]);
 }
Exemple #2
0
        public void ThenTheContent_TypeHeaderShouldBe(string contentType)
        {
            ExternalServiceBindings.ExternalService.RequestInfo requestInfo = ExternalServiceBindings.GetService(this.scenarioContext).Requests.Single();
            Assert.IsTrue(requestInfo.Headers.TryGetValue("Content-Type", out string contentTypeHeader), "Should contain Content-Type header");
            var parsedHeader = MediaTypeHeaderValue.Parse(contentTypeHeader);

            Assert.AreEqual(contentType, parsedHeader.MediaType);
        }
        public void ThenTheConditionEndpointShouldHaveBeenInvoked()
        {
            ExternalServiceBindings.ExternalService externalService = ExternalServiceBindings.GetService(this.scenarioContext);
            Assert.AreEqual(1, externalService.Requests.Count);
            this.requestInfo = externalService.Requests.Single();
            Assert.AreEqual(this.condition.ExternalUrl, this.requestInfo.Url.ToString());
            Assert.AreEqual("POST", this.requestInfo.Verb);

            IJsonSerializerSettingsProvider serializationSettingsProvider =
                ContainerBindings.GetServiceProvider(this.featureContext).GetRequiredService <IJsonSerializerSettingsProvider>();

            CommonSteps.RequestBody = JsonConvert.DeserializeObject <ExternalServiceWorkflowRequest>(
                this.requestInfo.RequestBody,
                serializationSettingsProvider.Instance);
        }
        public async Task GivenGivenIHaveCreatedAndPersistedAWorkflowContainingAnExternalConditionWithIdAsync(string workflowId)
        {
            ExternalServiceBindings.ExternalService externalService            = ExternalServiceBindings.GetService(this.scenarioContext);
            IServiceIdentityAccessTokenSource       serviceIdentityTokenSource =
                ContainerBindings.GetServiceProvider(this.featureContext).GetRequiredService <IServiceIdentityAccessTokenSource>();

            IJsonSerializerSettingsProvider serializerSettingsProvider =
                ContainerBindings.GetServiceProvider(this.featureContext).GetRequiredService <IJsonSerializerSettingsProvider>();

            Workflow workflow = ExternalConditionWorkflowFactory.Create(
                workflowId,
                externalService.TestUrl.ToString(),
                serviceIdentityTokenSource,
                serializerSettingsProvider);

            this.condition = workflow.GetInitialState().Transitions
                             .Single()
                             .Conditions
                             .OfType <InvokeExternalServiceCondition>()
                             .Single();

            ITenantedWorkflowStoreFactory storeFactory = ContainerBindings.GetServiceProvider(this.featureContext)
                                                         .GetService <ITenantedWorkflowStoreFactory>();

            ITenantProvider tenantProvider =
                ContainerBindings.GetServiceProvider(this.featureContext).GetRequiredService <ITenantProvider>();

            IWorkflowStore store = await storeFactory.GetWorkflowStoreForTenantAsync(tenantProvider.Root).ConfigureAwait(false);

            await WorkflowRetryHelper.ExecuteWithStandardTestRetryRulesAsync(async() =>
            {
                try
                {
                    Workflow oldWorkflow = await store.GetWorkflowAsync(workflowId).ConfigureAwait(false);
                    workflow.ETag        = oldWorkflow.ETag;
                }
                catch (WorkflowNotFoundException)
                {
                    // Don't care if there is no old workflow.
                }

                await store.UpsertWorkflowAsync(workflow).ConfigureAwait(false);
            }).ConfigureAwait(false);
        }
Exemple #5
0
 public void GivenTheExternalServiceResponseWillSpecifyContextItemsToRemove(Table table)
 {
     ExternalServiceBindings.ExternalService service = ExternalServiceBindings.GetService(this.scenarioContext);
     service.ActionResponseBody ??= new ExternalServiceWorkflowResponse();
     service.ActionResponseBody.ContextValuesToRemove = table.Rows.Select(x => x[0]).ToList();
 }
Exemple #6
0
 public void GivenITheExternalServiceWillReturnAStatus(int statusCode)
 {
     ExternalServiceBindings.GetService(this.scenarioContext).StatusCode = statusCode;
 }
 public void GivenTheExternalServiceResponseBodyWillContain(string content)
 {
     ExternalServiceBindings.ExternalService externalService = ExternalServiceBindings.GetService(this.scenarioContext);
     externalService.ConditionResponseBody = content;
 }