UpdateLinkCategory() public method

public UpdateLinkCategory ( LinkCategory lc ) : bool
lc Subtext.Framework.Components.LinkCategory
return bool
Beispiel #1
0
        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);
        }