public void ThenTheContentCalledShouldBeACopyOfTheContentCalled(string expectedName, string actualName)
        {
            Content expected = this.scenarioContext.Get <Content>(expectedName);
            Content actual   = this.scenarioContext.Get <Content>(actualName);

            ContentSpecHelpers.CompareACopy(expected, actual);
        }
        public void GivenIHaveCreatedContent(Table contentTable)
        {
            foreach (TableRow row in contentTable.Rows)
            {
                (Content content, string name) = ContentSpecHelpers.GetContentFor(row);
                if (row.ContainsKey("ContentSlug"))
                {
                    ContentSpecHelpers.SetContentWorkflow(content, row);
                }
                else if (row.ContainsKey("Fragment"))
                {
                    ContentSpecHelpers.SetContentFragment(content, row);
                }
                else if (row.ContainsKey("AbTestSetName"))
                {
                    ContentSpecHelpers.SetAbTestSet(this.scenarioContext, content, row);
                }
                else if (row.ContainsKey("Markdown"))
                {
                    ContentSpecHelpers.SetContentMarkdown(content, row);
                }
                else if (row.ContainsKey("Liquid template"))
                {
                    ContentSpecHelpers.SetContentLiquid(content, row);
                }
                else if (row.ContainsKey("Liquid with markdown template"))
                {
                    ContentSpecHelpers.SetContentLiquidMarkdown(content, row);
                }

                this.scenarioContext.Set(content, name);
            }
        }
        public void ThenTheContentSummariesCalledShouldMatch(string contentSummariesName, Table table)
        {
            ContentSummaries summaries = this.scenarioContext.Get <ContentSummaries>(contentSummariesName);
            var expected = table.Rows.Select(s => this.scenarioContext.Get <Content>(s["ContentName"])).ToList();

            ContentSpecHelpers.MatchSummariesToContent(expected, summaries);
        }
Ejemplo n.º 4
0
 public void GivenIHaveANewContentItem(Table table)
 {
     foreach (TableRow row in table.Rows)
     {
         (Cms.Content content, string name) = ContentSpecHelpers.GetContentFor(row);
         this.scenarioContext.Set(content, name);
     }
 }
Ejemplo n.º 5
0
        public void ThenTheResponseBodyShouldContainTheContentItem(string itemName)
        {
            SwaggerResponse <ContentResponse> actual = this.scenarioContext.GetLastApiResponse <ContentResponse>();

            Assert.IsNotNull(actual);

            Cms.Content expected = this.scenarioContext.Get <Cms.Content>(itemName);

            ContentSpecHelpers.Compare(expected, actual.Result);
        }
        public void ThenTheResponseBodyShouldContentStateMatching(string stateName)
        {
            SwaggerResponse <ContentStateResponse> actual = this.scenarioContext.GetLastApiResponse <ContentStateResponse>();

            Assert.IsNotNull(actual);

            Cms.ContentState expectedState = this.scenarioContext.Get <Cms.ContentState>(stateName);

            ContentSpecHelpers.Compare(expectedState, actual.Result);
        }
        public void ThenTheEmbeddedResourceCalledShouldMatchTheContentCalled(string linkRel, string expectedKey)
        {
            SwaggerResponse response = this.scenarioContext.GetLastApiResponse();
            Resource        resource = response.ResultAs <Resource>();

            ContentResponse actual = resource.GetEmbeddedDocument <ContentResponse>(linkRel);

            Cms.Content expected = this.scenarioContext.Get <Cms.Content>(expectedKey);

            ContentSpecHelpers.Compare(expected, actual);
        }
Ejemplo n.º 8
0
        public async Task GivenAContentItemHasBeenCreated(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.Content content, string name) = ContentSpecHelpers.GetContentFor(row);
                Cms.Content storedContent = await store.StoreContentAsync(content).ConfigureAwait(false);

                this.scenarioContext.Set(storedContent, name);
            }
        }
        public async Task GivenIHaveCreatedContentWithAnAbTestSet(Table contentTable)
        {
            IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);

            foreach (TableRow row in contentTable.Rows)
            {
                (Content content, string name) = ContentSpecHelpers.GetContentFor(row);
                ContentSpecHelpers.SetAbTestSet(this.scenarioContext, content, row);
                await store.StoreContentAsync(content).ConfigureAwait(false);

                this.scenarioContext.Set(content, 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);
            }
        }
Ejemplo n.º 11
0
        public async Task WhenIRequestThatTheContentIsCreated(string contentItem)
        {
            Cms.Content          item = this.scenarioContext.Get <Cms.Content>(contentItem);
            CreateContentRequest createContentRequest = ContentSpecHelpers.ContentAsCreateContentRequest(item);

            ContentClient client = this.featureContext.Get <ContentClient>();

            try
            {
                SwaggerResponse <ContentResponse> response = await client.CreateContentAsync(
                    this.featureContext.GetCurrentTenantId(),
                    item.Slug,
                    createContentRequest).ConfigureAwait(false);

                this.scenarioContext.StoreLastApiResponse(response);
            }
            catch (SwaggerException ex)
            {
                this.scenarioContext.StoreLastApiException(ex);
            }
        }