public void AdHomeSearchResultModel_ctor_callparentctor()
        {
            // Given
            AdSearchModel sM = new AdSearchModel();
            sM.SearchString = "prout";

            // When
            AdHomeSearchResultModel result = new AdHomeSearchResultModel(sM);

            // Then
            Assert.AreEqual(0, result.Results.Count);
            Assert.AreEqual("prout", result.SearchString);
        }
        public AdHomeSearchResultModel QuickSearch(AdSearchModel searchQuery)
        {
            String[] andSearchStrings = null;

            if (!String.IsNullOrEmpty(searchQuery.SearchString))
                andSearchStrings = searchQuery.SearchString.Trim().Split(' ');

            IDictionary<Category, int> searchResult = _searchRepository.CountByCategory(andSearchStrings, searchQuery.CitySelectedId);

            AdHomeSearchResultModel result = new AdHomeSearchResultModel(searchQuery);
            IList<Category> processedParentCategories = new List<Category>();

            // Loop through all the parent categories
            foreach (KeyValuePair<Category, int> r in searchResult)
            {
                Category parentCategory = r.Key.ParentCategory;

                if (processedParentCategories.Contains(parentCategory))
                    continue;

                processedParentCategories.Add(parentCategory);

                AdHomeSearchResultItemModel m = new AdHomeSearchResultItemModel(parentCategory);
                result.Results.Add(m);

                foreach (Category c in parentCategory.SubCategories)
                {
                    if (!searchResult.ContainsKey(c))
                        continue;

                    AdHomeSearchResultItemModel r1 = new AdHomeSearchResultItemModel(c);
                    r1.ResultCount = searchResult[c];
                    m.ResultCount += r1.ResultCount;
                    m.SubCategoriesResults.Add(r1);
                }

                result.SearchResultTotalCount += m.ResultCount;
            }

            return result;
        }