public async Task ShouldCallProviderWithExpectedParameters()
        {
            const int numberOfItemsToReturn = 10;
            const int pageNumber            = 1;

            _mockNameSearchProvider.Setup(m => m.SearchProviderNameAndAliases(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(new ProviderNameSearchResultsAndPagination());
            _mockPaginationSettings.Setup(p => p.DefaultResultsAmount).Returns(numberOfItemsToReturn);

            var providerNameSearchService = new ProviderNameSearchService(_mockPaginationSettings.Object, _mockNameSearchProvider.Object, _mockLogger.Object);

            await providerNameSearchService.SearchProviderNameAndAliases("test", pageNumber, null);

            _mockNameSearchProvider.Verify(x => x.SearchProviderNameAndAliases("test", pageNumber, numberOfItemsToReturn));
        }
        public async Task ShouldLogInitialDetailsWithExpectedParameters()
        {
            const int    numberOfItemsToReturn = 10;
            const int    pageNumber            = 1;
            const string searchTerm            = "test";

            _mockNameSearchProvider.Setup(m => m.SearchProviderNameAndAliases(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(new ProviderNameSearchResultsAndPagination());
            _mockPaginationSettings.Setup(p => p.DefaultResultsAmount).Returns(numberOfItemsToReturn);

            var providerNameSearchService = new ProviderNameSearchService(_mockPaginationSettings.Object, _mockNameSearchProvider.Object, _mockLogger.Object);

            await providerNameSearchService.SearchProviderNameAndAliases(searchTerm, pageNumber, null);

            var expected = $"Provider Name Search started: SearchTerm: [{searchTerm}], Page: [{pageNumber}], Page Size: [{numberOfItemsToReturn}]";

            _mockLogger.Verify(x => x.Info(expected));
        }
        public async Task ShouldLogErrorWithFailedCall()
        {
            const int    numberOfItemsToReturn = 10;
            const int    pageNumber            = 1;
            const string searchTerm            = "test";

            _mockNameSearchProvider.Setup(m => m.SearchProviderNameAndAliases(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Throws <Exception>();
            _mockPaginationSettings.Setup(p => p.DefaultResultsAmount).Returns(numberOfItemsToReturn);

            var providerNameSearchService = new ProviderNameSearchService(_mockPaginationSettings.Object, _mockNameSearchProvider.Object, _mockLogger.Object);

            var result = await providerNameSearchService.SearchProviderNameAndAliases(searchTerm, pageNumber, null);

            var expected = $"Provider Name Search error: SearchTerm: [{searchTerm}], Page: [{pageNumber}], Page Size: [{numberOfItemsToReturn}]";

            _mockLogger.Verify(x => x.Info(It.IsAny <string>()), Times.Once);
            _mockLogger.Verify(x => x.Error(It.IsAny <Exception>(), expected));
            Assert.IsTrue(result.HasError);
            Assert.AreEqual(ProviderNameSearchResponseCodes.SearchFailed, result.ResponseCode);
        }
        public async Task ShouldReturnSuccessCodeAndNotError()
        {
            const int    numberOfItemsToReturn = 10;
            const int    pageNumber            = 1;
            const string searchTerm            = "test";
            var          returnedResults       = new ProviderNameSearchResultsAndPagination {
                ActualPage = 1, HasError = false, TotalResults = 1
            };

            _mockNameSearchProvider.Setup(m => m.SearchProviderNameAndAliases(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(returnedResults));
            _mockPaginationSettings.Setup(p => p.DefaultResultsAmount).Returns(numberOfItemsToReturn);

            var providerNameSearchService = new ProviderNameSearchService(_mockPaginationSettings.Object, _mockNameSearchProvider.Object, _mockLogger.Object);

            var result = await providerNameSearchService.SearchProviderNameAndAliases(searchTerm, pageNumber, null);

            var expected = $"Provider Name Search complete: SearchTerm: [{searchTerm}], Page: [{result.ActualPage}], Page Size: [{numberOfItemsToReturn}], Total Results: [{result.TotalResults}]";

            _mockLogger.Verify(x => x.Info(expected));
            Assert.IsFalse(result.HasError);
            Assert.AreEqual(ProviderNameSearchResponseCodes.Success, result.ResponseCode);
        }