public async Task <GetSiteMapQueryResult <SiteMap> > Handle(GetSiteMapQuery request, CancellationToken cancellationToken) { var sitemap = await _apiClient.Get <Page <SiteMap> >(new GetSiteMapRequest()).ConfigureAwait(false); return(new GetSiteMapQueryResult <SiteMap> { Page = sitemap }); }
public async Task Then_The_Api_Is_Called_And_The_SiteMap_Is_Returned_From_The_Api( GetSiteMapQuery query, Page <SiteMap> response, [Frozen] Mock <IOptions <CampaignConfiguration> > config, [Frozen] Mock <IApiClient> client, GetSiteMapQueryHandler handler) { client.Setup(o => o.Get <Page <SiteMap> >(It.Is <GetSiteMapRequest>(r => r.GetUrl == $"sitemap"))).ReturnsAsync(response); var actual = await handler.Handle(query, CancellationToken.None); client.Verify(o => o.Get <Page <SiteMap> >(It.Is <GetSiteMapRequest>(r => r.GetUrl == $"sitemap")), Times.Once); actual.Should().NotBeNull(); actual.Page.Should().NotBeNull(); }
public async Task Then_The_Api_Is_Called_And_The_SiteMap_Is_Returned( GetSiteMapQuery query, CmsContent apiResponse, SiteMapPageModel response, [Frozen] Mock <IContentService> contentService, [Frozen] Mock <IReliableCacheStorageService> service, GetSiteMapQueryHandler handler) { contentService.Setup(x => x.HasContent(It.IsAny <ApiResponse <CmsContent> >())).Returns(true); service.Setup(o => o.GetData <CmsContent>( It.Is <GetSiteMapRequest>(c => c.GetUrl.Contains($"entries?content_type={query.ContentType}&include=2")), $"SiteMap_{query.ContentType}", contentService.Object.HasContent)) .ReturnsAsync(apiResponse); var actual = await handler.Handle(query, CancellationToken.None); actual.MapModel.Should().BeEquivalentTo(response.Build(apiResponse)); }