public async Task <IActionResult> GetProviderById(int year, int month, int day, string providerId)
        {
            Guard.ArgumentNotNull(day, nameof(day));
            Guard.ArgumentNotNull(month, nameof(month));
            Guard.ArgumentNotNull(year, nameof(year));
            Guard.IsNullOrWhiteSpace(providerId, nameof(providerId));

            ProviderVersionByDate providerVersionByDate = await _providerVersionService.GetProviderVersionByDate(year, month, day);

            if (providerVersionByDate != null)
            {
                return(await GetProviderById(providerVersionByDate.ProviderVersionId, providerId));
            }

            return(new NotFoundResult());
        }
        public async Task SearchProviders_WhenProviderIdExistsForDate_ProviderReturned(int day, int month, int year)
        {
            // Arrange
            ProviderVersionViewModel providerVersionViewModel = CreateProviderVersion();

            Provider provider = GetProvider();

            providerVersionViewModel.Providers   = providerVersionViewModel.Providers.Concat(new[] { provider });
            providerVersionViewModel.VersionType = ProviderVersionType.Custom;

            ICacheProvider cacheProvider = CreateCacheProvider();

            SearchResults <ProvidersIndex> searchResults = new SearchResults <ProvidersIndex> {
                Results = new List <Repositories.Common.Search.SearchResult <ProvidersIndex> > {
                    new Repositories.Common.Search.SearchResult <ProvidersIndex> {
                        Result = new ProvidersIndex {
                            ProviderVersionId = provider.ProviderVersionId, UKPRN = provider.UKPRN
                        }
                    }
                }
            };

            IProviderVersionService providerVersionService = CreateProviderVersionService();

            ISearchRepository <ProvidersIndex> searchRepository = CreateSearchRepository();

            searchRepository
            .Search(Arg.Any <string>(), Arg.Any <SearchParameters>())
            .Returns(searchResults);

            IProviderVersionSearchService providerService = CreateProviderVersionSearchService(cacheProvider: cacheProvider, searchRepository: searchRepository, providerVersionService: providerVersionService);

            providerVersionService
            .GetProviderVersionByDate(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <int>())
            .Returns <ProviderVersionByDate>(new ProviderVersionByDate {
                Day = day, Month = month, Year = year, ProviderVersionId = provider.ProviderVersionId
            });

            // Act
            IActionResult okRequest = await providerService.SearchProviders(year, month, day, new Models.SearchModel {
                Filters = new Dictionary <string, string[]> {
                    { "providerId", new List <string> {
                          provider.ProviderId
                      }.ToArray() }
                }
            });

            await searchRepository.Received(1)
            .Search(Arg.Any <string>(), Arg.Is <SearchParameters>(c => c.Filter.Contains(provider.ProviderId)));

            okRequest
            .Should()
            .BeOfType <OkObjectResult>();

            ((OkObjectResult)okRequest).Value
            .Should()
            .BeOfType <ProviderVersionSearchResults>();
        }
        public async Task GetProviderById_WhenProviderIdDoesNotExistsForDate_NotFoundReturned(int day, int month, int year)
        {
            // Arrange
            ProviderVersionViewModel providerVersionViewModel = CreateProviderVersion();

            Provider provider = GetProvider();

            providerVersionViewModel.Providers   = providerVersionViewModel.Providers.Concat(new[] { provider });
            providerVersionViewModel.VersionType = ProviderVersionType.Custom;

            ICacheProvider cacheProvider = CreateCacheProvider();

            SearchResults <ProvidersIndex> searchResults = new SearchResults <ProvidersIndex>();

            ISearchRepository <ProvidersIndex> searchRepository = CreateSearchRepository();

            searchRepository
            .Search(Arg.Any <string>(), Arg.Any <SearchParameters>())
            .Returns(searchResults);

            IProviderVersionService providerVersionService = CreateProviderVersionService();

            string providerVersionId = Guid.NewGuid().ToString();

            providerVersionService
            .GetProviderVersionByDate(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <int>())
            .Returns <ProviderVersionByDate>(new ProviderVersionByDate {
                Day = day, Month = month, Year = year, ProviderVersionId = providerVersionId
            });

            IProviderVersionSearchService providerService = CreateProviderVersionSearchService(cacheProvider: cacheProvider, searchRepository: searchRepository, providerVersionService: providerVersionService);

            // Act
            IActionResult notFoundRequest = await providerService.GetProviderById(year, month, day, "12345");

            await searchRepository.Received(1)
            .Search(Arg.Any <string>(), Arg.Is <SearchParameters>(c => c.Filter.Contains(providerVersionId)));

            notFoundRequest
            .Should()
            .BeOfType <NotFoundResult>();
        }