public virtual void CanGetSearchTotal()
        {
            var searchRequest = new AgencySearchRequest();
            searchRequest.AgencyQuery = "IT ";

            int results = _agencyRepository.GetSearchTotal(searchRequest);
            Assert.That(results == 1);
        }
        public virtual void CanSearch()
        {
            var searchRequest = new AgencySearchRequest();
            searchRequest.AgencyQuery = "e";

            IList<AgencyDto> results = _agencyRepository.Search(searchRequest, 0, 20);
            Assert.That(results.Count > 1 && results.Count <= 20);
        }
        public void CanListAgencies()
        {
            // Establish Context
            var viewModel = new SearchResultFormViewModel<AgencyDto, AgencySearchRequest>();
            IList<AgencyDto> agencySummariesToExpect = new List<AgencyDto>();
            viewModel.SearchRequest = new AgencySearchRequest();
            viewModel.PageResultItems = agencySummariesToExpect;

            var agencyDto = new AgencyDto();
            agencySummariesToExpect.Add(agencyDto);

            var searchRequest = new AgencySearchRequest {AgencyQuery = "test"};

            _agencySearchManagementService.Expect(r => r.CreateFormViewModel())
                .Return(viewModel);

            // Act
            ViewResult result = _agenciesController.Index().AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as SearchResultFormViewModel<AgencyDto, AgencySearchRequest>).ShouldNotBeNull();
            (result.ViewData.Model as SearchResultFormViewModel<AgencyDto, AgencySearchRequest>).PageResultItems.Count.
                ShouldEqual(1);
        }
 public ActionResult Search(AgencySearchRequest searchRequest)
 {
     SearchResultFormViewModel<AgencyDto, AgencySearchRequest> formViewModel = null;
     try
     {
         formViewModel = _agencySearchManagementService.Search(searchRequest);
         Session.Add(SEARCH_PARAMETERS, searchRequest);
     }
     catch (PreconditionException pde)
     {
         TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = pde.Message;
         formViewModel = _agencySearchManagementService.CreateFormViewModel(searchRequest);
     }
     return View("Index", formViewModel);
 }