Example #1
0
        public async Task OnGetAsync_GivenSearchResultsReturnsResults_ReturnsPage()
        {
            // Arrange
            IResultsApiClient resultsApiClient = CreateApiClient();

            IProviderSearchService searchService = CreateSearchService();

            ProviderSearchResultViewModel model = new ProviderSearchResultViewModel();

            searchService
            .PerformSearch(Arg.Any <SearchRequestViewModel>())
            .Returns(model);

            ViewProviderResultsPageModel pageModel = CreatePageModel(resultsApiClient, searchService);

            // Act
            IActionResult actionResult = await pageModel.OnGetAsync(1, string.Empty);

            // Assert
            actionResult
            .Should()
            .BeOfType <PageResult>();
        }
Example #2
0
        public async Task OnGetAsync_GivenNullSearchResultsReturns_ReturnsStatusCode500()
        {
            // Arrange
            IResultsApiClient resultsApiClient = CreateApiClient();

            IProviderSearchService searchService = CreateSearchService();

            searchService
            .PerformSearch(Arg.Any <SearchRequestViewModel>())
            .Returns((ProviderSearchResultViewModel)null);

            ViewProviderResultsPageModel pageModel = CreatePageModel(resultsApiClient, searchService);

            // Act
            IActionResult actionResult = await pageModel.OnGetAsync(1, string.Empty);

            // Assert
            actionResult
            .Should()
            .BeOfType <StatusCodeResult>()
            .Which.StatusCode
            .Should()
            .Be(500);
        }