public virtual void CanSearch() { var searchRequest = new OrgSearchRequest(); searchRequest.OrgQuery = "e"; IList <OrgDto> results = _orgRepository.Search(searchRequest, 0, 20); Assert.That(results.Count > 1 && results.Count <= 20); }
//private SearchResultFormViewModel<OrgDto, OrgSearchRequest> LoadSearchResults(OrgSearchRequest searchRequest) //{ // const int entriesPerPage = 20; // int offset = entriesPerPage * (searchRequest.CurrentPageNumber - 1); // IList<OrgDto> searchResultItems = _orgRepository.Search(searchRequest, offset, entriesPerPage); // var searchResultFormViewModel = CreateFormViewModel(searchRequest); // searchResultFormViewModel.PageResultItems = searchResultItems; // int resultCount = _orgRepository.GetSearchTotal(searchRequest); // searchResultFormViewModel.TotalResultCount = resultCount; // searchResultFormViewModel.CurrentPageNumber = searchRequest.CurrentPageNumber; // searchResultFormViewModel.TotalPageCount = resultCount / entriesPerPage; // if (resultCount % entriesPerPage > 0) // { // searchResultFormViewModel.TotalPageCount++; // } // return searchResultFormViewModel; //} public SearchResultFormViewModel <OrgDto, OrgSearchRequest> Search(OrgSearchRequest searchRequest) { //make sure at least one field set //Check.Require(searchRequest != null, "At least one field is required"); //if (searchRequest.AgencyId == null && String.IsNullOrEmpty(searchRequest.OrgQuery)) //{ // Check.Require(1 == 0, "At least one field is required"); //} if (searchRequest.CurrentPageNumber == 0) { searchRequest.CurrentPageNumber = 1; } if (string.IsNullOrEmpty(searchRequest.SortColumn)) { searchRequest.SortColumn = DEFAULT_SORT_COLUMN; searchRequest.SortOrder = DEFAULT_SORT_ORDER; } const int entriesPerPage = 20; int offset = entriesPerPage * (searchRequest.CurrentPageNumber - 1); IList <OrgDto> searchResultItems = _orgRepository.Search(searchRequest, offset, entriesPerPage); var searchResultFormViewModel = CreateFormViewModel(searchRequest); searchResultFormViewModel.PageResultItems = searchResultItems; int resultCount = _orgRepository.GetSearchTotal(searchRequest); searchResultFormViewModel.TotalResultCount = resultCount; searchResultFormViewModel.CurrentPageNumber = searchRequest.CurrentPageNumber; searchResultFormViewModel.TotalPageCount = resultCount / entriesPerPage; if (resultCount % entriesPerPage > 0) { searchResultFormViewModel.TotalPageCount++; } return(searchResultFormViewModel); }