public async Task Then_The_Api_Is_Called_With_The_Valid_Request_Parameters_And_The_Landing_Page_Is_Returned( GetLandingPageQuery 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, GetLandingPageQueryHandler handler) { contentService.Setup(x => x.HasContent(It.IsAny <ApiResponse <CmsContent> >())).Returns(true); service.Setup(o => o.GetData <CmsContent>( It.Is <GetLandingPageRequest>(c => c.GetUrl.Contains($"fields.hubType={query.Hub.ToTitleCase()}&fields.slug={query.Slug}")), $"{query.Hub.ToTitleCase()}_{query.Slug}_landingPage", 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)); }
public void TestInitialize() { this.fileInformationAggregator = new Mock <IFileInformationAggregator>(); this.getLandingPage = new Mock <IGetLandingPageDbStatement>(); this.target = new GetLandingPageQueryHandler( this.fileInformationAggregator.Object, this.getLandingPage.Object); }
public async Task And_The_Api_Is_Called_With_Invalid_Request_Parameters_For_Article_Page_Then_Landing_Page_Is_Returned( GetLandingPageQuery query, Page<LandingPage> pageResponse, [Frozen] Mock<IApiClient> client, [Frozen] Mock<IOptions<CampaignConfiguration>> config, GetLandingPageQueryHandler landingPageHandler) { SetupMockConfig(config); client.Setup(o => o.Get<Page<Article>>(It.Is<GetArticlesPreviewRequest>(r => r.GetUrl == $"article/preview/{query.Hub}/{query.Slug}"))).ReturnsAsync((Page<Article>)null); client.Setup(o => o.Get<Page<Article>>(It.Is<GetArticlesRequest>(r => r.GetUrl == $"article/{query.Hub}/{query.Slug}"))).ReturnsAsync((Page<Article>)null); client.Setup(o => o.Get<Page<LandingPage>>(It.Is<GetLandingPagePreviewRequest>(r => r.GetUrl == $"landingpage/{query.Hub}/{query.Slug}"))).ReturnsAsync(pageResponse); var actual = await landingPageHandler.Handle(query, CancellationToken.None); client.Verify(o => o.Get<Page<Article>>(It.IsAny<GetArticlesPreviewRequest>()), Times.Never); actual.Should().NotBeNull(); actual.Page.Should().NotBeNull(); }
public async Task Then_The_Api_Is_Called_With_The_Valid_Request_Parameters_Then_The_Landing_Page_Is_Returned_From_The_Api_With_The_Menu( bool preview, GetLandingPageQuery query, Page <LandingPage> response, [Frozen] Mock <IApiClient> client, [Frozen] Mock <IOptions <CampaignConfiguration> > config, GetLandingPageQueryHandler handler) { query.Preview = preview; SetupMockConfig(config, false); client.Setup(o => o.Get <Page <LandingPage> >(It.Is <GetLandingPageRequest>(r => r.GetUrl == $"landingpage/{query.Hub}/{query.Slug}"))).ReturnsAsync(response); var actual = await handler.Handle(query, CancellationToken.None); client.Verify( o => o.Get <Page <LandingPage> >(It.Is <GetLandingPageRequest>(r => r.GetUrl == $"landingpage/{query.Hub}/{query.Slug}")), Times.Once); client.Verify(o => o.Get <Page <LandingPage> >(It.IsAny <GetLandingPagePreviewRequest>()), Times.Never); actual.Should().NotBeNull(); actual.Page.Should().NotBeNull(); actual.Page.Content.Should().NotBeNull(); actual.Page.Menu.Should().NotBeNull(); actual.Page.Menu.Apprentices.Should().NotBeNullOrEmpty(); actual.Page.Menu.Influencers.Should().NotBeNullOrEmpty(); actual.Page.Menu.TopLevel.Should().NotBeNullOrEmpty(); actual.Page.Menu.Employers.Should().NotBeNullOrEmpty(); }
public async Task Then_The_Api_Is_Called_With_The_Valid_Request_Parameters_And_The_Landing_Page_Is_Returned_From_The_Preview_Api_if_Config_And_Param_Set( GetLandingPageQuery query, Page <LandingPage> response, [Frozen] Mock <IOptions <CampaignConfiguration> > config, [Frozen] Mock <IApiClient> client, GetLandingPageQueryHandler handler) { SetupMockConfig(config); query.Preview = true; client.Setup(o => o.Get <Page <LandingPage> >(It.Is <GetLandingPagePreviewRequest>(r => r.GetUrl == $"landingpage/preview/{query.Hub}/{query.Slug}"))).ReturnsAsync(response); var actual = await handler.Handle(query, CancellationToken.None); client.Verify(o => o.Get <Page <LandingPage> >(It.Is <GetLandingPagePreviewRequest>(r => r.GetUrl == $"landingpage/preview/{query.Hub}/{query.Slug}")), Times.Once); actual.Should().NotBeNull(); actual.Page.Should().NotBeNull(); }