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));
        }
Exemple #2
0
        public async Task Then_The_Api_Is_Called_With_The_Valid_Request_Parameters_And_The_Hub_Is_Returned(
            GetHubQuery query,
            GetMenuQueryResult menuResult,
            MenuPageModel.MenuPageContent menuContent,
            CmsContent apiResponse,
            HubPageModel response,
            GetBannerQueryResult bannerResult,
            BannerPageModel bannerContent,
            [Frozen] Mock <IContentService> contentService,
            [Frozen] Mock <IReliableCacheStorageService> service,
            [Frozen] Mock <IMediator> mediator,
            GetHubQueryHandler handler)
        {
            contentService.Setup(x => x.HasContent(It.IsAny <ApiResponse <CmsContent> >())).Returns(true);
            service.Setup(o =>
                          o.GetData <CmsContent>(
                              It.Is <GetHubEntriesRequest>(c =>
                                                           c.GetUrl.Contains($"fields.hubType={query.Hub.ToTitleCase()}")),
                              $"{query.Hub.ToTitleCase()}_hub", contentService.Object.HasContent))
            .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));
            service.Verify(x => x.GetData <CmsContent>(It.IsAny <GetHubEntriesRequest>(), It.IsAny <string>(), contentService.Object.HasContent), Times.Once);
        }