public void Then_The_Banner_Is_Built(CmsContent source, string contentValue)
        {
            source.Items[0].Fields.AllowUserToHideTheBanner = true;
            source.Items[0].Fields.ShowOnTheHomepageOnly    = true;

            foreach (var subContentItems in source.Items.FirstOrDefault().Fields.Content.Content)
            {
                subContentItems.NodeType = "paragraph";
                subContentItems.Content  = new List <ContentDefinition>
                {
                    new ContentDefinition
                    {
                        NodeType = "text",
                        Value    = contentValue
                    }
                };
            }

            var actual = new BannerPageModel().Build(source);

            actual.MainContent.Should().NotBeNullOrEmpty();
            actual.MainContent.ElementAt(0).Title.Should().NotBeNullOrWhiteSpace();
            actual.MainContent.ElementAt(0).AllowUserToHideTheBanner.Should().BeTrue();
            actual.MainContent.ElementAt(0).BackgroundColour.Should().NotBeNullOrWhiteSpace();
            actual.MainContent.ElementAt(0).ShowOnTheHomepageOnly.Should().BeTrue();
            actual.MainContent.ElementAt(0).Items.Any().Should().BeTrue();
        }
Exemplo n.º 2
0
        public async Task Then_The_Api_Is_Called_With_The_Valid_Request_Parameters_And_The_Article_Is_Returned(
            GetArticleByHubAndSlugQuery query,
            GetMenuQueryResult menuResult,
            GetBannerQueryResult bannerResult,
            MenuPageModel.MenuPageContent menuContent,
            BannerPageModel bannerContent,
            CmsContent apiResponse,
            CmsPageModel response,
            [Frozen] Mock <IContentService> contentService,
            [Frozen] Mock <IReliableCacheStorageService> service,
            [Frozen] Mock <IMediator> mediator,
            GetArticleByHubAndSlugQueryHandler handler)
        {
            contentService.Setup(x => x.HasContent(It.IsAny <ApiResponse <CmsContent> >())).Returns(true);
            service.Setup(o =>
                          o.GetData <CmsContent>(
                              It.Is <GetArticleEntriesRequest>(c =>
                                                               c.GetUrl.Contains($"fields.hubType={query.Hub.ToTitleCase()}&fields.slug={query.Slug}")),
                              $"{query.Hub.ToTitleCase()}_{query.Slug}_article", contentService.Object.HasContent))
            .ReturnsAsync(apiResponse);

            mediator.SetupMenu(menuResult, menuContent);
            mediator.SetupBanners(bannerResult, bannerContent);

            var actual = await handler.Handle(query, CancellationToken.None);

            var cmsPageModel = response.Build(apiResponse, menuContent, bannerContent);

            actual.PageModel.Should().BeEquivalentTo(cmsPageModel);
        }
        public async Task Then_The_Api_Is_Called_With_The_Valid_Request_Parameters_And_The_Landing_Page_Is_Returned(
            GetPreviewLandingPageQuery query,
            GetMenuQueryResult menuResult,
            MenuPageModel.MenuPageContent menuContent,
            CmsContent apiResponse,
            HubPageModel response,
            GetBannerQueryResult bannerResult,
            BannerPageModel bannerContent,
            [Frozen] Mock <IContentfulPreviewApiClient <ContentfulPreviewApiConfiguration> > apiClient,
            [Frozen] Mock <IMediator> mediator,
            GetPreviewLandingPageQueryHandler handler)
        {
            apiClient.Setup(o =>
                            o.Get <CmsContent>(
                                It.Is <GetLandingPageRequest>(c =>
                                                              c.GetUrl.Contains($"fields.hubType={query.Hub.ToTitleCase()}&fields.slug={query.Slug}"))))
            .ReturnsAsync(apiResponse);

            mediator.SetupMenu(menuResult, menuContent);
            mediator.SetupBanners(bannerResult, bannerContent);

            var actual = await handler.Handle(query, CancellationToken.None);

            actual.PageModel.Should().BeEquivalentTo(response.Build(apiResponse, menuContent, bannerContent));
        }
        public async Task <GetBannerQueryResult> Handle(GetBannerQuery request, CancellationToken cancellationToken)
        {
            var banner = await _reliableCacheStorageService.GetData <CmsContent>(new GetBannerRequest(), $"Banners", _contentService.HasContent);

            var pageModel = new BannerPageModel().Build(banner);

            return(new GetBannerQueryResult
            {
                PageModel = pageModel
            });
        }
        public void Then_If_Total_Is_Zero_Items_Returned_Then_Null_Returned(CmsContent source)
        {
            //Arrange
            source.Total = 0;

            //Act
            var actual = new BannerPageModel().Build(source);

            //Assert
            actual.Should().BeNull();
        }
        public void Then_If_No_Items_Returned_Then_Null_Returned()
        {
            //Arrange
            var source = new CmsContent {
                Items = new List <Item>(), Total = 1
            };

            //Act
            var actual = new BannerPageModel().Build(source);

            //Assert
            actual.Should().BeNull();
        }
        public async Task Then_The_Api_Is_Called_And_The_Banner_Is_Returned(
            GetBannerQuery query,
            CmsContent apiResponse,
            BannerPageModel response,
            [Frozen] Mock <IContentService> contentService,
            [Frozen] Mock <IReliableCacheStorageService> service,
            GetBannerQueryHandler handler)
        {
            contentService.Setup(x => x.HasContent(It.IsAny <ApiResponse <CmsContent> >())).Returns(true);
            service.Setup(o =>
                          o.GetData <CmsContent>(
                              It.Is <GetBannerRequest>(c =>
                                                       c.GetUrl.Contains($"entries?content_type=banner")),
                              $"Banners", contentService.Object.HasContent))
            .ReturnsAsync(apiResponse);

            var actual = await handler.Handle(query, CancellationToken.None);

            actual.PageModel.Should().BeEquivalentTo(response.Build(apiResponse));
        }
Exemplo n.º 8
0
        public void Then_The_Content_Items_Are_Added_For_Links(CmsContent source, string contentValue, string uri, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            var expectedUri = $"https://{uri}/";

            foreach (var subContentItems in source.Items.FirstOrDefault().Fields.Content.Content)
            {
                subContentItems.NodeType = "paragraph";
                subContentItems.Content  = new List <ContentDefinition>
                {
                    new ContentDefinition
                    {
                        NodeType = "hyperlink",
                        Content  = new List <RelatedContent>
                        {
                            new RelatedContent
                            {
                                Value = contentValue,
                            }
                        },
                        Data = new RelatedData
                        {
                            Uri = new Uri(expectedUri)
                        }
                    }
                };
            }

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.Items.TrueForAll(c => c.Type.Equals("paragraph")).Should().BeTrue();
            actual.MainContent.Items.TrueForAll(c => c.Values.FirstOrDefault().ToString() == $"[{contentValue}]({expectedUri})").Should().BeTrue();
        }
Exemplo n.º 9
0
        public void Then_If_Content_Contains_HyperLink_The_Content_Items_Are_Added_For_ListItems(CmsContent source, string contentValue, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            foreach (var subContentItems in source.Items.FirstOrDefault().Fields.Content.Content)
            {
                subContentItems.NodeType = "unordered-list";
                subContentItems.Content  = new List <ContentDefinition>
                {
                    new ContentDefinition
                    {
                        NodeType = "list-item",
                        Content  = new List <RelatedContent>
                        {
                            new RelatedContent
                            {
                                NodeType = "paragraph",
                                Content  = new List <RelatedContent>
                                {
                                    new RelatedContent
                                    {
                                        NodeType = "hyperlink",
                                        Content  = new List <RelatedContent>
                                        {
                                            new RelatedContent
                                            {
                                                NodeType = "text",
                                                Value    = "find"
                                            }
                                        },
                                        Data = new RelatedData {
                                            Uri = new Uri("http://www.google.com")
                                        }
                                    },
                                    new RelatedContent
                                    {
                                        NodeType = "text",
                                        Value    = " a website"
                                    }
                                }
                            }
                        }
                    },
                    new ContentDefinition
                    {
                        NodeType = "list-item",
                        Content  = new List <RelatedContent>
                        {
                            new RelatedContent
                            {
                                Content = new List <RelatedContent>
                                {
                                    new RelatedContent
                                    {
                                        Value = contentValue
                                    }
                                }
                            }
                        }
                    }
                };
            }

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.Items.TrueForAll(c => c.Type.Equals("unordered-list")).Should().BeTrue();
            actual.MainContent.Items[2].TableValue[0].Count.Should().Be(2);
            actual.MainContent.Items[2].TableValue[0].FirstOrDefault().Should().Be("[find](http://www.google.com/)");
        }
Exemplo n.º 10
0
        public void Then_If_Total_Is_Zero_Items_Returned_Then_Null_Returned(CmsContent source, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            source.Total = 0;

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.Should().BeNull();
        }
Exemplo n.º 11
0
        public void Then_The_Embedded_Items_Are_Added(CmsContent source, string contentValue, string linkedContentId, AssetFields fields, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            fields.File.Url = $"//{fields.File.Url}";
            source.Items.FirstOrDefault().Fields.Content.Content = new List <SubContentItems>
            {
                new SubContentItems
                {
                    NodeType = "embedded-asset-block",
                    Content  = new List <ContentDefinition>(),
                    Data     = new PurpleData
                    {
                        Target = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = linkedContentId,
                                LinkType = "Asset"
                            }
                        }
                    }
                }
            };
            source.Includes.Asset = new List <Asset>()
            {
                new Asset
                {
                    Sys = new AssetSys
                    {
                        Id = linkedContentId,
                    },
                    Fields = fields
                }
            };

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.Items[0].Type.Should().Be("embedded-asset-block");
            actual.MainContent.Items[0].EmbeddedResource.Id.Should().Be(linkedContentId);
            actual.MainContent.Items[0].EmbeddedResource.Title.Should().Be(fields.Title);
            actual.MainContent.Items[0].EmbeddedResource.FileName.Should().Be(fields.File.FileName);
            actual.MainContent.Items[0].EmbeddedResource.Url.Should().Be($"https:{fields.File.Url}");
            actual.MainContent.Items[0].EmbeddedResource.ContentType.Should().Be(fields.File.ContentType);
            actual.MainContent.Items[0].EmbeddedResource.Size.Should().Be(fields.File.Details.Size);
            actual.MainContent.Items[0].EmbeddedResource.Description.Should().Be(fields.Description);
        }
Exemplo n.º 12
0
        public void Then_The_Content_Items_Are_Added_For_ListItems_with_Styling(string listType, CmsContent source, string contentValue, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            foreach (var subContentItems in source.Items.FirstOrDefault().Fields.Content.Content)
            {
                subContentItems.NodeType = listType;
                subContentItems.Content  = new List <ContentDefinition>
                {
                    new ContentDefinition
                    {
                        NodeType = "list-item",
                        Content  = new List <RelatedContent>
                        {
                            new RelatedContent
                            {
                                NodeType = "paragraph",
                                Content  = new List <RelatedContent>
                                {
                                    new RelatedContent
                                    {
                                        NodeType = "text",
                                        Value    = contentValue,
                                        Marks    = new List <SysElement>
                                        {
                                            new SysElement
                                            {
                                                Type = "Bold"
                                            }
                                        }
                                    }
                                }
                            },
                            new RelatedContent
                            {
                                NodeType = "text",
                                Value    = contentValue,
                                Marks    = new List <SysElement>
                                {
                                    new SysElement
                                    {
                                        Type = "Italic"
                                    }
                                }
                            }
                        }
                    }
                };
            }

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.Items[0].Type.Should().Be(listType);
            actual.MainContent.Items[0].TableValue[0].FirstOrDefault().Should().Be($"[Bold]{contentValue}");
            actual.MainContent.Items[0].TableValue[1].FirstOrDefault().Should().Be($"[Italic]{contentValue}");
            actual.MainContent.Items[0].TableValue.Count.Should().Be(2);
        }
Exemplo n.º 13
0
        public void Then_The_Header_Image_Is_Added(CmsContent source, string contentValue, AssetFields fields, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            fields.File.Url = $"//{fields.File.Url}";

            source.Includes.Asset = new List <Asset>()
            {
                new Asset
                {
                    Sys = new AssetSys
                    {
                        Id = source.Items[0].Fields.HeaderImage.Sys.Id
                    },
                    Fields = fields
                }
            };

            ////Act
            var actual = new LandingPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.HeaderImage.Should().NotBeNull();
            actual.MainContent.HeaderImage.EmbeddedResource.Id.Should().Be(source.Items[0].Fields.HeaderImage.Sys.Id);
            actual.MainContent.HeaderImage.EmbeddedResource.Title.Should().Be(fields.Title);
            actual.MainContent.HeaderImage.EmbeddedResource.FileName.Should().Be(fields.File.FileName);
            actual.MainContent.HeaderImage.EmbeddedResource.Url.Should().Be($"https:{fields.File.Url}");
            actual.MainContent.HeaderImage.EmbeddedResource.ContentType.Should().Be(fields.File.ContentType);
            actual.MainContent.HeaderImage.EmbeddedResource.Size.Should().Be(fields.File.Details.Size);
            actual.MainContent.HeaderImage.EmbeddedResource.Description.Should().Be(fields.Description);
        }
Exemplo n.º 14
0
        public void Then_The_PageType_Is_Correctly_Set(string pageType, PageType type, CmsContent source, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            source.Items.FirstOrDefault().Sys.ContentType.Sys.Id = pageType;

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.PageAttributes.PageType.Should().Be(type);
        }
Exemplo n.º 15
0
        public void Then_The_Attachments_Are_Built(CmsContent source, EntryFields linkedPage, AssetFields fields, string linkedContentId, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            fields.File.Url = $"//{fields.File.Url}";
            source.Items.FirstOrDefault().Fields.Attachments = new List <LandingPage>
            {
                new LandingPage
                {
                    Sys = new LandingPageSys
                    {
                        Id       = linkedContentId,
                        Type     = "Link",
                        LinkType = "Asset"
                    }
                }
            };
            source.Includes.Asset = new List <Asset>()
            {
                new Asset
                {
                    Sys = new AssetSys
                    {
                        Id = linkedContentId,
                    },
                    Fields = fields
                }
            };

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.Attachments.Count.Should().Be(1);
            actual.Attachments[0].Id.Should().Be(linkedContentId);
            actual.Attachments[0].Title.Should().Be(fields.Title);
            actual.Attachments[0].Url.Should().Be($"https:{fields.File.Url}");
            actual.Attachments[0].ContentType.Should().Be(fields.File.ContentType);
            actual.Attachments[0].FileName.Should().Be(fields.File.FileName);
            actual.Attachments[0].Size.Should().Be(fields.File.Details.Size);
            actual.Attachments[0].Description.Should().Be(fields.Description);
        }
Exemplo n.º 16
0
        public static void SetupBanners(this Mock <IMediator> mediator, GetBannerQueryResult bannerResult, BannerPageModel bannerModel)
        {
            mediator.Setup(o => o.Send(It.IsAny <GetBannerQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(bannerResult);

            bannerModel.MainContent = bannerResult.PageModel.MainContent;
        }
Exemplo n.º 17
0
        public void Then_The_Cards_Are_Built(CmsContent source, EntryFields linkedPage, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            source.Items[0].Fields.Cards[0].Sys.Id = "2K5MZPYdhDNyPEsDk4EgZh";
            source.Includes.Entry = new List <Entry>
            {
                new Entry
                {
                    Sys = new AssetSys
                    {
                        Id    = "2K5MZPYdhDNyPEsDk4EgZh",
                        Space = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "123abc",
                                Type     = "Link",
                                LinkType = "Space"
                            }
                        },
                        ContentType = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "article",
                                LinkType = "ContentType",
                                Type     = "Link",
                            }
                        }
                    },
                    Fields = linkedPage
                }
            };

            //Act
            var actual = new LandingPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.Cards.Count.Should().Be(1);
            actual.MainContent.Cards.TrueForAll(c => c.Title.Equals(linkedPage.Title)).Should().BeTrue();
            actual.MainContent.Cards.TrueForAll(c => c.Summary.Equals(linkedPage.Summary)).Should().BeTrue();
            actual.MainContent.Cards.TrueForAll(c => c.Slug.Equals(linkedPage.Slug)).Should().BeTrue();
            actual.MainContent.Cards.TrueForAll(c => c.HubType.Equals(linkedPage.HubType)).Should().BeTrue();
            actual.MainContent.Cards.TrueForAll(c => c.MetaDescription.Equals(linkedPage.MetaDescription)).Should().BeTrue();
        }
Exemplo n.º 18
0
        public void Then_If_No_Items_Returned_Then_Null_Returned(MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            var source = new CmsContent {
                Items = new List <Item>(), Total = 1
            };

            //Act
            var actual = new LandingPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.Should().BeNull();
        }
Exemplo n.º 19
0
        public void Then_No_Content_Items_Returns_Empty_List(CmsContent source, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            source.Items.FirstOrDefault().Fields.Content = null;

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.Items.Should().BeEmpty();
        }
Exemplo n.º 20
0
        public void Then_The_Page_Level_Fields_Are_Set(CmsContent source, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.PageAttributes.Title.Should().Be(source.Items.FirstOrDefault()?.Fields.Title);
            actual.PageAttributes.MetaDescription.Should().Be(source.Items.FirstOrDefault()?.Fields.MetaDescription);
            actual.PageAttributes.Slug.Should().Be(source.Items.FirstOrDefault()?.Fields.Slug);
            actual.PageAttributes.HubType.Should().Be(source.Items.FirstOrDefault()?.Fields.HubType);
            actual.PageAttributes.Summary.Should().Be(source.Items.FirstOrDefault()?.Fields.Summary);
        }
Exemplo n.º 21
0
        public void Then_The_Related_Articles_Are_Built(CmsContent source, EntryFields linkedPage, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            source.Includes.Entry = new List <Entry>
            {
                new Entry
                {
                    Sys = new AssetSys
                    {
                        Id    = "321EDF",
                        Space = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "123abc",
                                Type     = "Link",
                                LinkType = "Space"
                            }
                        },
                        ContentType = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "landingPage",
                                LinkType = "ContentType",
                                Type     = "Link",
                            }
                        }
                    },
                    Fields = linkedPage
                },
                new Entry
                {
                    Sys = new AssetSys
                    {
                        Id    = "321EDC",
                        Space = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "123abc",
                                Type     = "Link",
                                LinkType = "Space",
                            }
                        },
                        ContentType = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "article",
                                LinkType = "ContentType",
                                Type     = "Link",
                            }
                        }
                    },
                    Fields = linkedPage
                }
            };

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.RelatedArticles.Count.Should().Be(1);
            actual.RelatedArticles.TrueForAll(c => c.Title.Equals(linkedPage.Title)).Should().BeTrue();
            actual.RelatedArticles.TrueForAll(c => c.Summary.Equals(linkedPage.Summary)).Should().BeTrue();
            actual.RelatedArticles.TrueForAll(c => c.Slug.Equals(linkedPage.Slug)).Should().BeTrue();
            actual.RelatedArticles.TrueForAll(c => c.HubType.Equals(linkedPage.HubType)).Should().BeTrue();
            actual.RelatedArticles.TrueForAll(c => c.MetaDescription.Equals(linkedPage.MetaDescription)).Should().BeTrue();
        }
Exemplo n.º 22
0
        public void Then_No_Content_Items_Returns_Empty_Header_Image_And_Cards(CmsContent source, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            source.Items.FirstOrDefault().Fields.HeaderImage = null;

            //Act
            var actual = new LandingPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.HeaderImage.Should().BeNull();
            actual.MainContent.Cards.Should().BeEmpty();
        }
Exemplo n.º 23
0
        public void Then_Any_Linked_Types_Are_Added_To_The_Content_Items(CmsContent source, string contentValue, string linkedContentId, List <List <string> > tableData, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            source.Items.FirstOrDefault().Fields.Content.Content = new List <SubContentItems>
            {
                new SubContentItems
                {
                    NodeType = "paragraph",
                    Content  = new List <ContentDefinition>
                    {
                        new ContentDefinition
                        {
                            Content = new List <RelatedContent>(),
                            Data    = new RelatedData
                            {
                                Target = new LandingPage
                                {
                                    Sys = new LandingPageSys
                                    {
                                        Id = linkedContentId
                                    }
                                }
                            },
                            NodeType = "embedded-entry-inline"
                        }
                    }
                }
            };
            source.Includes.Entry = new List <Entry>
            {
                new Entry
                {
                    Sys = new AssetSys
                    {
                        Id = linkedContentId,
                    },
                    Fields = new EntryFields
                    {
                        Table = new Table
                        {
                            TableData = tableData
                        }
                    }
                }
            };

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.Items.TrueForAll(c => c.Type.Equals("paragraph")).Should().BeTrue();
            actual.MainContent.Items.FirstOrDefault().TableValue.Should().BeEquivalentTo(tableData);
        }
Exemplo n.º 24
0
        public void Then_If_No_Parent_Page_Is_Set_Then_Null_Returned_For_Parent_Page(CmsContent source, string parentId, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            source.Items.FirstOrDefault().Fields.LandingPage = null;


            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.ParentPage.Should().BeNull();
        }
Exemplo n.º 25
0
        public void Then_Any_Tabbed_Content_Is_Added_To_The_Content_Items(CmsContent source, EntryFields linkedPage, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            source.Items.FirstOrDefault().Fields.TabbedContents[0].Sys.Id = "321EDF";
            source.Items.FirstOrDefault().Fields.TabbedContents[1].Sys.Id = "321EDC";
            //Arrange
            source.Includes.Entry = new List <Entry>
            {
                new Entry
                {
                    Sys = new AssetSys
                    {
                        Id    = "321EDF",
                        Space = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "123abc",
                                Type     = "Link",
                                LinkType = "Space"
                            }
                        },
                        ContentType = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "tab",
                                LinkType = "ContentType",
                                Type     = "Link",
                            }
                        }
                    },
                    Fields = linkedPage
                },
                new Entry
                {
                    Sys = new AssetSys
                    {
                        Id    = "321EDC",
                        Space = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "123abc",
                                Type     = "Link",
                                LinkType = "Space",
                            }
                        },
                        ContentType = new LandingPage
                        {
                            Sys = new LandingPageSys
                            {
                                Id       = "tab",
                                LinkType = "ContentType",
                                Type     = "Link",
                            }
                        }
                    },
                    Fields = linkedPage
                }
            };

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.TabbedContents.Any().Should().BeTrue();
            actual.TabbedContents.FirstOrDefault().TabTitle.Should().NotBeNullOrWhiteSpace();
            actual.TabbedContents.FirstOrDefault().TabName.Should().NotBeNullOrWhiteSpace();
        }
Exemplo n.º 26
0
        public void Then_The_Content_Items_Are_Added_For_Block_Quotes(CmsContent source, string contentValue, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            foreach (var subContentItems in source.Items.FirstOrDefault().Fields.Content.Content)
            {
                subContentItems.NodeType = "blockquote";
                subContentItems.Content  = new List <ContentDefinition>
                {
                    new ContentDefinition
                    {
                        NodeType = "paragraph",
                        Content  = new List <RelatedContent>
                        {
                            new RelatedContent
                            {
                                NodeType = "text",
                                Value    = contentValue
                            }
                        }
                    }
                };
            }

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.Items.Should().NotBeEmpty();
            actual.MainContent.Items.TrueForAll(c => c.Type.Equals("blockquote")).Should().BeTrue();
            actual.MainContent.Items.TrueForAll(c => c.Values.FirstOrDefault().Equals(contentValue)).Should().BeTrue();
        }
Exemplo n.º 27
0
        public void Then_The_Parent_Page_Is_Set(CmsContent source, string parentId, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            source.Items.FirstOrDefault().Fields.LandingPage.Sys.Id = parentId;
            source.Includes.Entry.FirstOrDefault().Sys.Id = parentId;

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.ParentPage.Title.Should().Be(source.Includes.Entry.FirstOrDefault()?.Fields.Title);
            actual.ParentPage.MetaDescription.Should().Be(source.Includes.Entry.FirstOrDefault()?.Fields.MetaDescription);
            actual.ParentPage.Slug.Should().Be(source.Includes.Entry.FirstOrDefault()?.Fields.Slug);
            actual.ParentPage.HubType.Should().Be(source.Includes.Entry.FirstOrDefault()?.Fields.HubType);
            actual.ParentPage.Summary.Should().Be(source.Includes.Entry.FirstOrDefault()?.Fields.Summary);
        }
Exemplo n.º 28
0
        public void Then_The_Content_Items_Are_Added_For_Hr_Content_Type(CmsContent source, string contentValue, MenuPageModel.MenuPageContent menuContent, BannerPageModel bannerContent)
        {
            //Arrange
            foreach (var subContentItems in source.Items.FirstOrDefault().Fields.Content.Content)
            {
                subContentItems.NodeType = "hr";
                subContentItems.Content  = new List <ContentDefinition>();
            }

            //Act
            var actual = new CmsPageModel().Build(source, menuContent, bannerContent);

            //Assert
            actual.MainContent.Items.Should().NotBeEmpty();
            actual.MainContent.Items.TrueForAll(c => c.Type.Equals("hr")).Should().BeTrue();
            actual.MainContent.Items.TrueForAll(c => c.Values.Count.Equals(0)).Should().BeTrue();
        }