public async Task WhenIGetTheContentSummariesForSlugWithLimitAndContinuationTokenAndCallIt(string slug, int limit, string continuationToken, string contentSummariesName) { IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext); ContentSummaries summaries = await store.GetContentSummariesAsync(SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug), limit, SpecHelpers.ParseSpecValue <string>(this.scenarioContext, continuationToken)).ConfigureAwait(false); this.scenarioContext.Set(summaries, contentSummariesName); }
public static async Task CreateContentStateTestData(FeatureContext featureContext) { ITenantedContentStoreFactory contentStoreFactory = ContainerBindings.GetServiceProvider(featureContext).GetRequiredService <ITenantedContentStoreFactory>(); IContentStore store = await contentStoreFactory.GetContentStoreForTenantAsync(featureContext.GetCurrentTenantId()).ConfigureAwait(false); for (int i = 0; i < 30; i++) { var state = new ContentState { Id = Guid.NewGuid().ToString(), ContentId = SpecHelpers.ParseSpecValue <string>(featureContext, $"{{Content{i}.Id}}"), Slug = SpecHelpers.ParseSpecValue <string>(featureContext, $"{{Content{i}.Slug}}"), WorkflowId = "workflow1id", ChangedBy = new CmsIdentity(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()), }; if (i < 4) { state.StateName = "draft"; } else if (i < 29) { state.StateName = "published"; } else { state.StateName = "archived"; } ContentState storedContentState = await store.SetContentWorkflowStateAsync(state.Slug, state.ContentId, state.WorkflowId, state.StateName, state.ChangedBy).ConfigureAwait(false); featureContext.Set(storedContentState, $"Content{i}-State"); } }
public async Task GivenIDraftTheContentWithSlug(string slug) { IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext); await store.MakeDraftContentAsync( SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug), new CmsIdentity("SomeId", "SomeName")).ConfigureAwait(false); }
public async Task WhenIGetTheContentPublicationStateForSlugAndCallItAsync(string slug, string contentName) { IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext); ContentState content = await store.GetContentPublicationStateAsync(SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug)).ConfigureAwait(false); this.scenarioContext.Set(content, contentName); }
public void ThenGettingThePublishedContentForSlugThrowsAContentNotFoundException(string slug) { IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext); Assert.ThrowsAsync <ContentNotFoundException>( () => store.GetPublishedContentAsync(SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug)), "ContentNotFoundException should have been thrown."); }
public void ThenTheETagHeaderShouldBeSetTo(string property) { SwaggerResponse response = this.scenarioContext.GetLastApiResponse(); string etagHeader = response.Headers["ETag"]?.First(); string expected = SpecHelpers.ParseSpecValue <string>(this.scenarioContext, property); Assert.AreEqual(expected, etagHeader); }
public async Task WhenICopyTheContentFromSlugToAndCallIt(string sourceSlug, string destinationSlug, string copyName) { IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext); Content result = await store.CopyContentForPublicationAsync( SpecHelpers.ParseSpecValue <string>(this.scenarioContext, destinationSlug), SpecHelpers.ParseSpecValue <string>(this.scenarioContext, sourceSlug), new CmsIdentity("SomeId", "SomeName")).ConfigureAwait(false); this.scenarioContext.Set(result, copyName); }
public async Task WhenIGetThePublishedStateHistoryAndCorrespondingContentSummariesForSlugAndCallIt(string slug, int limit, string continuationToken, string name) { IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext); ContentStates states = await store.GetPublishedHistory( SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug), limit, SpecHelpers.ParseSpecValue <string>(this.scenarioContext, continuationToken)).ConfigureAwait(false); List <ContentSummary> summaries = await store.GetContentSummariesForStatesAsync(states.States).ConfigureAwait(false); this.scenarioContext.Set((states, summaries), name); }
public async Task GivenAWorkflowStateHasBeenSetForTheContentItem(Table table) { ITenantedContentStoreFactory contentStoreFactory = ContainerBindings.GetServiceProvider(this.featureContext).GetRequiredService <ITenantedContentStoreFactory>(); IContentStore store = await contentStoreFactory.GetContentStoreForTenantAsync(this.featureContext.GetCurrentTenantId()).ConfigureAwait(false); foreach (TableRow row in table.Rows) { (Cms.ContentState state, string name) = ContentSpecHelpers.GetContentStateFor(row); // Cater for the fact that the content item could be in either of scenario or feature context. state.ContentId = SpecHelpers.ParseSpecValue <string>(this.scenarioContext, state.ContentId); state.ContentId = SpecHelpers.ParseSpecValue <string>(this.featureContext, state.ContentId); Cms.ContentState storedContentState = await store.SetContentWorkflowStateAsync(state.Slug, state.ContentId, state.WorkflowId, state.StateName, state.ChangedBy).ConfigureAwait(false); this.scenarioContext.Set(storedContentState, name); } }
private async Task GetWorkflowStateHistoryAndStoreResponseAsync(string slug, string workflowId, int?limit, string continuationToken, string embed) { string resolvedSlug = SpecHelpers.ParseSpecValue <string>(this.featureContext, slug); string resolvedWorkflowId = SpecHelpers.ParseSpecValue <string>(this.featureContext, workflowId); Embed2?resolvedEmbed = string.IsNullOrEmpty(embed) ? (Embed2?)null : Enum.Parse <Embed2>(embed, true); ContentClient client = this.featureContext.Get <ContentClient>(); SwaggerResponse <ContentStatesResponse> response = await client.GetWorkflowHistoryAsync( this.featureContext.GetCurrentTenantId(), resolvedWorkflowId, resolvedSlug, limit, continuationToken, resolvedEmbed).ConfigureAwait(false); this.scenarioContext.StoreLastApiResponse(response); }
public async Task WhenIGetThePublicationHistoryForSlugWithLimitAndContinuationTokenAndCallItAsync(string slug, int limit, string continuationTokenSource, string contentSummariesName) { IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext); string continuationToken = continuationTokenSource == null ? null : this.scenarioContext.Get <(ContentStates States, List <ContentSummary> Summaries)>(continuationTokenSource).States.ContinuationToken; ContentStates states = await store.GetPublicationHistory( SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug), limit, continuationToken).ConfigureAwait(false); List <ContentSummary> summaries = await store.GetContentSummariesForStatesAsync(states.States).ConfigureAwait(false); this.scenarioContext.Set((states, summaries), contentSummariesName); }
private async Task RequestContentHistoryAndStoreResponseAsync( string slug, int?limit, string continuationToken, string etag) { string resolvedSlug = SpecHelpers.ParseSpecValue <string>(this.featureContext, slug); ContentClient client = this.featureContext.Get <ContentClient>(); SwaggerResponse <ContentSummariesResponse> response = await client.GetContentHistoryAsync( this.featureContext.GetCurrentTenantId(), resolvedSlug, limit, continuationToken, etag).ConfigureAwait(false); this.scenarioContext.StoreLastApiResponse(response); }
private async Task RequestContentSummaryAndStoreResponseAsync(string slug, string id, string etag) { string resolvedSlug = SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug); string resolvedId = SpecHelpers.ParseSpecValue <string>(this.scenarioContext, id); try { ContentClient client = this.featureContext.Get <ContentClient>(); SwaggerResponse <ContentSummaryResponse> response = await client.GetContentSummaryAsync( this.featureContext.GetCurrentTenantId(), resolvedSlug, resolvedId, etag).ConfigureAwait(false); this.scenarioContext.StoreLastApiResponse(response); } catch (SwaggerException ex) { this.scenarioContext.StoreLastApiException(ex); } }
public async Task WhenIRequestTheWorkflowStateForSlugAndWorkflowIdWithEmbedded(string embed, string slug, string workflowId) { string resolvedSlug = SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug); string resolvedWorkflowId = SpecHelpers.ParseSpecValue <string>(this.scenarioContext, workflowId); Embed? resolvedEmbed = string.IsNullOrEmpty(embed) ? (Embed?)null : Enum.Parse <Embed>(embed, true); try { ContentClient client = this.featureContext.Get <ContentClient>(); SwaggerResponse <ContentStateResponse> response = await client.GetWorkflowStateAsync( this.featureContext.GetCurrentTenantId(), resolvedSlug, resolvedWorkflowId, resolvedEmbed).ConfigureAwait(false); this.scenarioContext.StoreLastApiResponse(response); } catch (SwaggerException ex) { this.scenarioContext.StoreLastApiException(ex); } }
public void ThenTheOutputCalledShouldMatch(string outputName, string outputString) { Assert.AreEqual(SpecHelpers.ParseSpecValue <string>(this.scenarioContext, outputString), this.scenarioContext.Get <string>(outputName)); }