public void SearchForConcepts_Returns_All_Concepts_When_No_SearchFields_Is_Specified()
        {
            A.CallTo(() => _conceptRepository.SearchForConcepts(_noSearchFields))
            .Returns(_conceptsInDatabase);

            var conceptsFromService = _service.SearchForConcepts(_noSearchFields);

            Assert.Equal(conceptsFromService.Count, _conceptsInDatabase.Count);
        }
예제 #2
0
        public void SearchForConcepts_Fetches_Concepts_When_Query_Is_Specified()
        {
            A.CallTo(() => ConceptRepository.SearchForConcepts(A <ConceptSearchQuery> ._)).Returns(new List <Concept>());
            var results = Service.SearchForConcepts(new ConceptSearchQuery());

            A.CallTo(() => ConceptRepository.GetAll(BaseListQuery)).Returns(new List <Concept>());
            A.CallTo(() => ConceptRepository.SearchForConcepts(A <ConceptSearchQuery> ._)).Returns(new List <Concept>());

            Assert.IsType <PagingDTO <ConceptDto> >(results.Data);
        }
예제 #3
0
        public Response SearchForConcepts(ConceptSearchQuery query)
        {
            try
            {
                var concepts      = _conceptRepository.SearchForConcepts(query);
                var totalItems    = 0;
                var numberOfPages = 0;

                try
                {
                    totalItems    = concepts.FirstOrDefault().TotalItems;
                    numberOfPages = concepts.FirstOrDefault().NumberOfPages;
                }
                catch { }

                var res = new PagingDTO <ConceptDto>(
                    Mapper.Map <List <ConceptDto> >(concepts),
                    query,
                    UrlHelper.Action("Search", "Concept", query),
                    numberOfPages,
                    totalItems);


                return(new Response
                {
                    Data = res
                });
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public void SearchForConcepts_Returns_All_Concepts_If_No_SearchFields_Is_Specified()
        {
            var searchResult = _repository.SearchForConcepts(new ConceptSearchFields());

            Assert.Equal(_conceptsInDatabase.Count, searchResult.Count);
        }
예제 #5
0
 public List <Concept> SearchForConcepts(ConceptSearchFields searchFields)
 {
     return(_conceptRepository.SearchForConcepts(searchFields));
 }