public async Task ForDirectCategoriesReturnsCorrrectEmail(Category selectedCategory, string expectedEmail) { // arrange var routingService = new RoutingService(FamApiRoutingOptions, fakeApiDataProcessorService, fakeHttpClient); // act var result = await routingService.GetEmailToSendTo(ValidPostcode, selectedCategory).ConfigureAwait(false); // assert A.CallTo(() => fakeApiDataProcessorService.GetAsync <RoutingDetailModel>(A <HttpClient> .Ignored, A <Uri> .Ignored)).MustNotHaveHappened(); result.Should().Be(expectedEmail); }
private async Task <string> GetFamRoutingEmailAddress(string postCode) { var url = new Uri($"{famApiRoutingOptions.BaseAddress}{famApiRoutingOptions.AreaRoutingEndpoint}{postCode}", UriKind.Absolute); var famRouting = await apiDataProcessorService.GetAsync <RoutingDetailModel>(httpClient, url).ConfigureAwait(false); return(famRouting?.EmailAddress ?? famApiRoutingOptions.FallbackEmailToAddresses); }
public async Task <TModel?> GetItemAsync <TModel>(string contentType, Guid id) where TModel : class, IApiDataModel { var uri = new Uri($"{cmsApiClientOptions.BaseAddress}/{contentType}/{id}", UriKind.Absolute); return(await apiDataProcessorService.GetAsync <TModel>(httpClient, uri).ConfigureAwait(false)); }
public async Task CmsApiServiceGetSummaryReturnsNullFornNData() { // arrange IList <ApiSummaryModel>?nullExpectedResults = null; A.CallTo(() => fakeApiDataProcessorService.GetAsync <IList <ApiSummaryModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).Returns(nullExpectedResults); var cmsApiService = new CmsApiService(CmsApiClientOptions, fakeApiDataProcessorService, fakeHttpClient, mapper, A.Fake <IApiCacheService>(), A.Fake <IContentTypeMappingService>()); // act var result = await cmsApiService.GetSummaryAsync <ApiSummaryModel>().ConfigureAwait(false); // assert A.CallTo(() => fakeApiDataProcessorService.GetAsync <IList <ApiSummaryModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).MustHaveHappenedOnceExactly(); Assert.Equal(result, nullExpectedResults); }