private void ResetMocks() { AddressSearchService.Reset(); OnspdSearchClient.Reset(); ProviderSearchClient.Reset(); BinaryStorageProvider.Reset(); }
private void ResetMocks() { AddressSearchService.Reset(); BlobServiceClient.Reset(); ProviderSearchClient.Reset(); BinaryStorageProvider.Reset(); LarsSearchClient.Reset(); LarsSearchSettings.Reset(); }
public async Task ProviderSearch_Get_WithSearchQuery_ReturnsExpectedContent() { // Arrange var searchQuery = "TestSearchQuery"; var request = new HttpRequestMessage(HttpMethod.Get, $"/provider-search?SearchQuery={searchQuery}"); var providerSearchResult1 = CreateProviderSearchResult(1); var providerSearchResult2 = CreateProviderSearchResult(2, ProviderStatus.Registered); var providerSearchResult3 = CreateProviderSearchResult(3, ProviderStatus.Unregistered); var providerSearchResult4 = CreateProviderSearchResult(4, providerStatus: null); var searchResult = new SearchResult <Provider> { Items = new[] { new SearchResultItem <Provider> { Record = providerSearchResult1 }, new SearchResultItem <Provider> { Record = providerSearchResult2 }, new SearchResultItem <Provider> { Record = providerSearchResult3 }, new SearchResultItem <Provider> { Record = providerSearchResult4 } } }; ProviderSearchClient.Setup(s => s.Search(It.Is <ProviderSearchQuery>(q => q.SearchText == searchQuery))) .ReturnsAsync(searchResult); // Act var response = await HttpClient.SendAsync(request); //Assert response.StatusCode.Should().Be(StatusCodes.Status200OK); var doc = await response.GetDocument(); doc.Body.TextContent.Should().NotContain("No providers found"); doc.GetElementByTestId("search-query-input").Attributes["value"].Value.Should().Be(searchQuery); var provider1SearchResultRow = doc.GetElementByTestId($"search-result-row-{providerSearchResult1.ProviderId}"); var provider2SearchResultRow = doc.GetElementByTestId($"search-result-row-{providerSearchResult2.ProviderId}"); var provider3SearchResultRow = doc.GetElementByTestId($"search-result-row-{providerSearchResult3.ProviderId}"); var provider4SearchResultRow = doc.GetElementByTestId($"search-result-row-{providerSearchResult4.ProviderId}"); using (new AssertionScope()) { provider1SearchResultRow.Should().NotBeNull(); provider1SearchResultRow.GetElementByTestId("provider-name").TextContent.Should().Be(providerSearchResult1.ProviderName); provider1SearchResultRow.GetElementByTestId("provider-action").TextContent.Trim().Should().Be("View dashboard"); provider2SearchResultRow.Should().NotBeNull(); provider2SearchResultRow.GetElementByTestId("provider-name").TextContent.Should().Be(providerSearchResult2.ProviderName); provider2SearchResultRow.GetElementByTestId("provider-action").TextContent.Trim().Should().Be("Add provider"); provider3SearchResultRow.Should().NotBeNull(); provider3SearchResultRow.GetElementByTestId("provider-name").TextContent.Should().Be(providerSearchResult3.ProviderName); provider3SearchResultRow.GetElementByTestId("provider-action").TextContent.Trim().Should().BeEmpty(); provider4SearchResultRow.Should().NotBeNull(); provider4SearchResultRow.GetElementByTestId("provider-name").TextContent.Should().Be(providerSearchResult4.ProviderName); provider4SearchResultRow.GetElementByTestId("provider-action").TextContent.Trim().Should().BeEmpty(); } }