Пример #1
0
        public List<TaxonomyCategory> GetOperatorTaxonomy(int companyId)
        {
            var categories = new List<TaxonomyCategory>();
            using (var connection = CreateConnection())
            {
                using (var command = CreateCommand(connection, "[easds].GetCompanyTaxonomies", new { @CompanyId = companyId }))
                {
                    var sqlReader = command.ExecuteReader();
                    while (sqlReader.Read())
                    {
                        var category = new TaxonomyCategory
                        {
                            CategoryId = sqlReader.GetValue<int>("liCategoryID"),
                            CategoryName = sqlReader.GetValue<string>("sCategoryName")
                        };
                        categories.Add(category);
                    }

                    sqlReader.NextResult();

                    while (sqlReader.Read())
                    {
                        int categoryId = sqlReader.GetValue<int>("liCategoryID");
                        var category = categories.Find(i => i.CategoryId == categoryId);
                        var categoryItem = new TaxonomyCategoryItem()
                        {
                            CategoryItemId =sqlReader.GetValue<int>("liCategoryItemID"),
                            CategoryItemName = sqlReader.GetValue<string>("sItemName"),
                            ParentItemId = sqlReader.GetValue<int>("liParentID")
                        };
                        category.AddItem(categoryItem);
                    }
                }
            }
            return categories;
        }
Пример #2
0
        public void ArticleController_Get_ArticleWithTaxonomy_ReturnedArticleHasTaxonomyInfo()
        {
            TaxonomyCategory category =   new TaxonomyCategory() {  CategoryId=1, CategoryName="ArticleSection"  };
            category.AddItem(new TaxonomyCategoryItem() { CategoryItemId = 1, CategoryItemName = "test", ParentItemId = null });
            List<TaxonomyCategory> categories = new List<TaxonomyCategory>() {category };

            _articleTaxonomyRepository.Stub(r => r.Get(Arg<int>.Is.Anything)).Return(categories);
            _articleRepository.Stub(r => r.Get(Arg<int>.Is.Anything)).Return(new Article());
            _urlHelper.Stub(h => h.GenerateUrl(Arg<String>.Is.Anything, Arg<Object>.Is.Anything)).Return("http://dummylink.co.uk");
            _staticContentLinkService.Stub(s => s.GetStaticContentLinkForSite()).Return(new List<StaticContentLink>());

            var articleFeed = _objectUnderTest.Get(1);

            var article = (Article)articleFeed.Entries.FirstOrDefault().Content;
            Assert.IsNotNull(article.Taxonomy);
        }
Пример #3
0
        public void TaxonomyController_GetAllTaxonomyCategories_ReturnsListOfTaxonomyCategoriesAndItems()
        {
            TaxonomyCategory category = new TaxonomyCategory() { CategoryId = 1, CategoryName = "ArticleSection" };
            category.AddItem(new TaxonomyCategoryItem() { CategoryItemId = 1, CategoryItemName = "test", ParentItemId = null });
            List<TaxonomyCategory> categories = new List<TaxonomyCategory>() { category };
            _taxonomyRepository.Stub(s => s.GetAllTaxonomyCategoriesAndItems()).Return(categories);

            var list = _objectUnderTest.GetAllTaxonomyCategories();
            Assert.IsNotNull(list);
        }