Example #1
0
 public static void CompareACopy(Cms.Content expected, Cms.Content actual)
 {
     // The slug and ID are expected to differ.
     CompareCommonElements(expected, actual);
     ComparePayloads(expected.ContentPayload, actual.ContentPayload);
     Assert.AreEqual(new ContentReference(expected.Slug, expected.Id), actual.OriginalSource.Value);
 }
Example #2
0
 public static void Compare(Cms.Content expected, Cms.Content actual)
 {
     CompareCommonElements(expected, actual);
     ComparePayloads(expected.ContentPayload, actual.ContentPayload);
     Assert.AreEqual(expected.Id, actual.Id);
     Assert.AreEqual(expected.Slug, actual.Slug);
     Assert.AreEqual(expected.OriginalSource, actual.OriginalSource);
 }
Example #3
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);
        }
Example #4
0
 public static void Compare(Cms.Content expected, Cms.ContentSummary actual)
 {
     Assert.AreEqual(expected.Id, actual.Id);
     Assert.AreEqual(expected.Slug, actual.Slug);
     Assert.AreEqual(expected.Author, actual.Author);
     Assert.AreEqual(string.Join(';', expected.CategoryPaths), string.Join(';', actual.CategoryPaths));
     Assert.AreEqual(string.Join(';', expected.Tags), string.Join(';', actual.Tags));
     Assert.AreEqual(expected.Culture, actual.Culture);
     Assert.AreEqual(expected.Description, actual.Description);
     Assert.AreEqual(expected.Title, actual.Title);
 }
        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);
        }
Example #6
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);
            }
        }
Example #7
0
        public static (Cms.Content, string) GetContentFor(TableRow row)
        {
            var content = new Cms.Content
            {
                Id          = SpecHelpers.PerformSubstitutions(row["Id"]),
                Author      = new Cms.CmsIdentity(SpecHelpers.PerformSubstitutions(row["Author.Id"]), SpecHelpers.PerformSubstitutions(row["Author.Name"])),
                Culture     = CultureInfo.GetCultureInfo(SpecHelpers.PerformSubstitutions(row["Culture"])),
                Description = SpecHelpers.PerformSubstitutions(row["Description"]),
                Slug        = SpecHelpers.PerformSubstitutions(row["Slug"]),
                Title       = SpecHelpers.PerformSubstitutions(row["Title"]),
            };

            content.CategoryPaths.AddRange(SplitAndTrim(SpecHelpers.PerformSubstitutions(row["CategoryPaths"])));
            content.Tags.AddRange(SplitAndTrim(SpecHelpers.PerformSubstitutions(row["Tags"])));

            return(content, row["Name"]);
Example #8
0
 public static CreateContentRequest ContentAsCreateContentRequest(Cms.Content item)
 {
     return(new CreateContentRequest
     {
         Author = new Cms.Api.Client.CmsIdentity
         {
             UserId = item.Author.UserId,
             UserName = item.Author.UserName,
         },
         CategoryPaths = new ObservableCollection <string>(item.CategoryPaths),
         Culture = item.Culture?.Name,
         Description = item.Description,
         Id = item.Id,
         Tags = new ObservableCollection <string>(item.Tags),
         Title = item.Title,
         ContentPayload = ContentPayloadAsCreateContentRequestPayload(item.ContentPayload),
     });
 }
Example #9
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);
            }
        }
Example #10
0
 /// <summary>
 /// Sets a content fragment payload on a content instance.
 /// </summary>
 /// <param name="scenarioContext">The scenario context.</param>
 /// <param name="content">The content instance on which to set the payload.</param>
 /// <param name="row">The row from which to get the content fragment.</param>
 public static void SetAbTestSet(ScenarioContext scenarioContext, Cms.Content content, TableRow row)
 {
     content.ContentPayload = scenarioContext.Get <AbTestSetPayload>(row["AbTestSetName"]);
 }
Example #11
0
 /// <summary>
 /// Sets a Liquid with markdown payload on a content instance.
 /// </summary>
 /// <param name="content">The content instance on which to set the payload.</param>
 /// <param name="row">The row from which to get the markdown.</param>
 public static void SetContentLiquidMarkdown(Cms.Content content, TableRow row)
 {
     content.ContentPayload = new LiquidWithMarkdownPayload {
         Template = SpecHelpers.PerformSubstitutions(row["Liquid with markdown template"])
     };
 }
Example #12
0
 /// <summary>
 /// Sets a markdown payload on a content instance.
 /// </summary>
 /// <param name="content">The content instance on which to set the payload.</param>
 /// <param name="row">The row from which to get the markdown.</param>
 public static void SetContentMarkdown(Cms.Content content, TableRow row)
 {
     content.ContentPayload = new MarkdownPayload {
         Markdown = SpecHelpers.PerformSubstitutions(row["Markdown"])
     };
 }
Example #13
0
 /// <summary>
 /// Sets a content workflow payload on a content instance.
 /// </summary>
 /// <param name="content">The content instance on which to set the payload.</param>
 /// <param name="row">The row from which to get the slug for the workflow content.</param>
 public static void SetContentWorkflow(Cms.Content content, TableRow row)
 {
     content.ContentPayload = new PublicationWorkflowContentPayload {
         Slug = SpecHelpers.PerformSubstitutions(row["ContentSlug"])
     };
 }
Example #14
0
 /// <summary>
 /// Sets a content fragment payload on a content instance.
 /// </summary>
 /// <param name="content">The content instance on which to set the payload.</param>
 /// <param name="row">The row from which to get the content fragment.</param>
 public static void SetContentFragment(Cms.Content content, TableRow row)
 {
     content.ContentPayload = new ContentFragmentPayload {
         Fragment = SpecHelpers.PerformSubstitutions(row["Fragment"])
     };
 }