public async Task GetLocalAuthoritiesByProviderVersionId_WhenProviderVersionIdFacetProvidedWithNoAuthorities_OkWithEmptyResultReturned() { // Arrange string authorityFacet = "authority"; string providerVersionIdFacet = "providerVersionId"; string providerVersionId = "dsg-2020-07-03"; SearchResults <ProvidersIndex> authorityResults = new SearchResults <ProvidersIndex> { Facets = new List <Facet> { new Facet { Name = authorityFacet, FacetValues = Enumerable.Empty <FacetValue>() } } }; SearchResults <ProvidersIndex> providerVersionResults = new SearchResults <ProvidersIndex> { Facets = new List <Facet> { new Facet { Name = providerVersionIdFacet, FacetValues = new List <FacetValue> { new FacetValue { Name = providerVersionId } } } } }; ISearchRepository <ProvidersIndex> searchRepository = CreateSearchRepository(); searchRepository .Search(string.Empty, Arg.Is <SearchParameters>(x => x.Facets.Any(x => x.Contains(authorityFacet)))) .Returns(authorityResults); searchRepository .Search(string.Empty, Arg.Is <SearchParameters>(x => x.Facets.Any(x => x.Contains(providerVersionIdFacet)))) .Returns(providerVersionResults); searchRepository .Search(string.Empty, Arg.Is <SearchParameters>(x => x.Facets == null || !x.Facets.Any())) .Returns(new SearchResults <ProvidersIndex>()); IProviderVersionSearchService providerService = CreateProviderVersionSearchService(searchRepository: searchRepository); // Act IActionResult notFoundRequest = await providerService.GetLocalAuthoritiesByProviderVersionId(providerVersionId); // Assert notFoundRequest .Should() .BeOfType <OkObjectResult>(); ((IEnumerable <string>)((OkObjectResult)notFoundRequest).Value).Should().BeEmpty(); }
public async Task <IActionResult> GetLocalAuthorityNamesByProviderVersionId([FromRoute] string providerVersionId) { return(await _providerVersionSearchService.GetLocalAuthoritiesByProviderVersionId(providerVersionId)); }