public async Task ThenTheWorkflowInstanceWithIdShouldContainContextItems(string instanceId, Table expectedContextItems) { ITenantedWorkflowInstanceStoreFactory instanceStoreFactory = ContainerBindings.GetServiceProvider(this.featureContext) .GetService <ITenantedWorkflowInstanceStoreFactory>(); ITenantProvider tenantProvider = ContainerBindings.GetServiceProvider(this.featureContext) .GetService <ITenantProvider>(); IWorkflowInstanceStore instanceStore = await instanceStoreFactory.GetWorkflowInstanceStoreForTenantAsync(tenantProvider.Root).ConfigureAwait(false); WorkflowInstance instance = await WorkflowRetryHelper.ExecuteWithStandardTestRetryRulesAsync( () => instanceStore.GetWorkflowInstanceAsync(instanceId)).ConfigureAwait(false); Assert.AreEqual( expectedContextItems.Rows.Count, instance.Context.Count, "The number of context items in the workflow instance is different to the number of items in the specified list"); foreach (TableRow current in expectedContextItems.Rows) { Assert.IsTrue( instance.Context.TryGetValue(current[0], out string actualValue), $"The instance context does not contain expected item with key '{current[0]}'"); Assert.AreEqual(current[1], actualValue, $"The instance context does not contain the expected value for key '{current[0]}'"); } }
public async Task ThenTheWorkflowInstanceWithIdShouldHaveStatus(string instanceId, string expectedStatus) { ITenantedWorkflowInstanceStoreFactory instanceStoreFactory = ContainerBindings.GetServiceProvider(this.featureContext) .GetService <ITenantedWorkflowInstanceStoreFactory>(); ITenantProvider tenantProvider = ContainerBindings.GetServiceProvider(this.featureContext) .GetService <ITenantProvider>(); IWorkflowInstanceStore instanceStore = await instanceStoreFactory.GetWorkflowInstanceStoreForTenantAsync(tenantProvider.Root).ConfigureAwait(false); WorkflowInstance instance = await WorkflowRetryHelper.ExecuteWithStandardTestRetryRulesAsync( () => instanceStore.GetWorkflowInstanceAsync(instanceId)).ConfigureAwait(false); Assert.AreEqual(expectedStatus, instance.Status.ToString()); }
private async Task <WorkflowInstance> GetWorkflowInstance(string id, bool failTestOnException = true) { await this.EnsureWorkflowInstanceIsNotBeingModified(id).ConfigureAwait(false); ITenantedWorkflowInstanceStoreFactory storeFactory = this.serviceProvider.GetRequiredService <ITenantedWorkflowInstanceStoreFactory>(); IWorkflowInstanceStore store = await storeFactory.GetWorkflowInstanceStoreForTenantAsync(this.transientTenantManager.PrimaryTransientClient).ConfigureAwait(false); try { WorkflowInstance instance = await store.GetWorkflowInstanceAsync(id).ConfigureAwait(false); return(instance); } catch (Exception ex) when(failTestOnException) { Assert.Fail($"Couldn't find an instance with id {id}: {ex}"); } return(null); }
public async Task ThenTheWorkflowInstanceWithIdShouldBeInTheStateCalled(string instanceId, string stateName) { ITenantedWorkflowStoreFactory storeFactory = ContainerBindings.GetServiceProvider(this.featureContext) .GetService <ITenantedWorkflowStoreFactory>(); ITenantedWorkflowInstanceStoreFactory instanceStoreFactory = ContainerBindings.GetServiceProvider(this.featureContext) .GetService <ITenantedWorkflowInstanceStoreFactory>(); ITenantProvider tenantProvider = ContainerBindings.GetServiceProvider(this.featureContext) .GetService <ITenantProvider>(); IWorkflowStore store = await storeFactory.GetWorkflowStoreForTenantAsync(tenantProvider.Root).ConfigureAwait(false); IWorkflowInstanceStore instanceStore = await instanceStoreFactory.GetWorkflowInstanceStoreForTenantAsync(tenantProvider.Root).ConfigureAwait(false); WorkflowInstance instance = await WorkflowRetryHelper.ExecuteWithStandardTestRetryRulesAsync( () => instanceStore.GetWorkflowInstanceAsync(instanceId)).ConfigureAwait(false); Workflow workflow = await WorkflowRetryHelper.ExecuteWithStandardTestRetryRulesAsync( () => store.GetWorkflowAsync(instance.WorkflowId)).ConfigureAwait(false); WorkflowState currentState = workflow.GetState(instance.StateId); Assert.AreEqual(stateName, currentState.DisplayName); }