public async Task OnGetAsync_GivenNullResultsReturned_ReturnsInternalServerError() { //Arrange CalculationSearchResultViewModel viewModel = null; ICalculationSearchService searchService = CreateCalculationService(); searchService .PerformSearch(Arg.Any <SearchRequestViewModel>()) .Returns(viewModel); ViewCalculationResultsModel pageModel = CreatePageModel(searchService); //Act IActionResult result = await pageModel.OnGetAsync(null, ""); //Assert await searchService .Received(1) .PerformSearch(Arg.Is <SearchRequestViewModel>( m => m.PageNumber == null && m.IncludeFacets == false && m.SearchTerm == "" )); result .Should() .BeOfType <InternalServerErrorResult>(); pageModel .SearchTerm .Should() .BeNullOrWhiteSpace(); }
public async Task OnGetAsync_GivenageNumber_CallsSearchWithCorrentPageNumber() { //Arrange CalculationSearchResultViewModel viewModel = CreateCalculationSearchResultViewModel(); ICalculationSearchService searchService = CreateCalculationService(); searchService .PerformSearch(Arg.Any <SearchRequestViewModel>()) .Returns(viewModel); ViewCalculationResultsModel pageModel = CreatePageModel(searchService); //Act IActionResult result = await pageModel.OnGetAsync(2, ""); //Assert await searchService .Received(1) .PerformSearch(Arg.Is <SearchRequestViewModel>( m => m.PageNumber == 2 && m.IncludeFacets == false && m.SearchTerm == "" )); result .Should() .BeOfType <PageResult>(); }