GetCategories() public method

Gets the categories for the specified category type.
public GetCategories ( CategoryType catType, bool activeOnly ) : IList
catType CategoryType Type of the cat.
activeOnly bool if set to true [active only].
return IList
コード例 #1
0
ファイル: LinksTests.cs プロジェクト: rsaladrigas/Subtext
        public void CreateLinkCategoryAssignsUniqueCatIDs()
        {
            UnitTestHelper.SetupBlog();
            var repository = new DatabaseObjectProvider();
            // Create some categories
            CreateSomeLinkCategories(repository);
            ICollection<LinkCategory> linkCategoryCollection = repository.GetCategories(CategoryType.LinkCollection,
                                                                                   ActiveFilter.None);

            LinkCategory first = null;
            LinkCategory second = null;
            LinkCategory third = null;
            foreach (LinkCategory linkCategory in linkCategoryCollection)
            {
                if (first == null)
                {
                    first = linkCategory;
                    continue;
                }

                if (second == null)
                {
                    second = linkCategory;
                    continue;
                }

                if (third == null)
                {
                    third = linkCategory;
                    continue;
                }
            }

            // Ensure the CategoryIDs are unique
            Assert.AreNotEqual(first.Id, second.Id);
            Assert.AreNotEqual(first.Id, third.Id);
            Assert.AreNotEqual(second.Id, third.Id);
        }
コード例 #2
0
ファイル: LinksTests.cs プロジェクト: rsaladrigas/Subtext
        public void UpdateLinkCategoryIsFine()
        {
            UnitTestHelper.SetupBlog();
            var repository = new DatabaseObjectProvider();
            // Create the categories
            CreateSomeLinkCategories(repository);

            // Retrieve the categories, grab the first one and update it
            ICollection<LinkCategory> originalCategories = repository.GetCategories(CategoryType.LinkCollection,
                                                                               ActiveFilter.None);
            Assert.Greater(originalCategories.Count, 0, "Expected some categories in there.");
            LinkCategory linkCat = null;
            foreach (LinkCategory linkCategory in originalCategories)
            {
                linkCat = linkCategory;
                break;
            }
            LinkCategory originalCategory = linkCat;
            originalCategory.Description = "New Description";
            originalCategory.IsActive = false;
            bool updated = repository.UpdateLinkCategory(originalCategory);

            // Retrieve the categories and find the one we updated
            ICollection<LinkCategory> updatedCategories = repository.GetCategories(CategoryType.LinkCollection,
                                                                              ActiveFilter.None);
            LinkCategory updatedCategory = null;
            foreach (LinkCategory lc in updatedCategories)
            {
                if (lc.Id == originalCategory.Id)
                {
                    updatedCategory = lc;
                }
            }

            // Ensure the update was successful
            Assert.IsTrue(updated);
            Assert.IsNotNull(updatedCategory);
            Assert.AreEqual("New Description", updatedCategory.Description);
            Assert.AreEqual(false, updatedCategory.IsActive);
        }
コード例 #3
0
ファイル: LinksTests.cs プロジェクト: rsaladrigas/Subtext
        public void CanGetPostCollectionCategories()
        {
            UnitTestHelper.SetupBlog();
            var repository = new DatabaseObjectProvider();
            CreateSomePostCategories(repository);

            // Retrieve the categories, grab the first one and update it
            ICollection<LinkCategory> originalCategories = repository.GetCategories(CategoryType.PostCollection,
                                                                               ActiveFilter.None);
            Assert.IsTrue(originalCategories.Count > 0);
        }