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));
        }
Esempio 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);
        }
Esempio n. 3
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;
        }