public void CanGetCategoriesByPostId() { UnitTestHelper.SetupBlog(); int category1Id = Links.CreateLinkCategory(CreateCategory("Post Category 1", "Cody roolz!", CategoryType.PostCollection, true)); int category2Id = Links.CreateLinkCategory(CreateCategory("Post Category 2", "Cody roolz again!", CategoryType.PostCollection, true)); Links.CreateLinkCategory(CreateCategory("Post Category 3", "Cody roolz and again!", CategoryType.PostCollection, true)); Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("phil", "title", "body"); int entryId = UnitTestHelper.Create(entry); ObjectProvider.Instance().SetEntryCategoryList(entryId, new[] { category1Id, category2Id }); ICollection <LinkCategory> categories = Links.GetLinkCategoriesByPostId(entryId); Assert.AreEqual(2, categories.Count, "Expected two of the three categories"); Assert.AreEqual(category1Id, categories.First().Id); Assert.AreEqual(category2Id, categories.ElementAt(1).Id); Assert.AreEqual(Config.CurrentBlog.Id, categories.First().BlogId); }
public void CanUpdateLink() { UnitTestHelper.SetupBlog(); // Create the categories CreateSomeLinkCategories(); int categoryId = Links.CreateLinkCategory(CreateCategory("My Favorite Feeds", "Some of my favorite RSS feeds", CategoryType.LinkCollection, true)); Link link = CreateLink("Test", categoryId, null); int linkId = link.Id; Link loaded = ObjectProvider.Instance().GetLink(linkId); Assert.AreEqual("Test", loaded.Title); Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "test"); //Make changes then update. link.PostId = entry.Id; link.Title = "Another title"; link.NewWindow = true; ObjectProvider.Instance().UpdateLink(link); loaded = ObjectProvider.Instance().GetLink(linkId); Assert.AreEqual("Another title", loaded.Title); Assert.IsTrue(loaded.NewWindow); Assert.AreEqual(entry.Id, loaded.PostId); }
public PagedEntryByCategoryCollectionTester() { var category = new LinkCategory { BlogId = Config.CurrentBlog.Id, IsActive = true, Title = "Foobar", Description = "Unit Test" }; _categoryId = Links.CreateLinkCategory(category); }
/// <summary> /// Creates a blog post link category. /// </summary> /// <param name="blogId">The blog id.</param> /// <param name="title">The title.</param> /// <param name="categoryType">Type of the category.</param> /// <returns></returns> public static int CreateCategory(int blogId, string title, CategoryType categoryType) { var category = new LinkCategory { BlogId = Config.CurrentBlog.Id, Title = title, CategoryType = categoryType, IsActive = true }; return(Links.CreateLinkCategory(category)); }
// w.bloggar workarounds/nominal MT support - HACKS // w.bloggar is not correctly implementing metaWeblogAPI on its getRecentPost call, it wants // an instance of blogger.getRecentPosts at various time. // // What works better with w.bloggar is to tell it to use MT settings. For w.bloggar users // with metaWeblog configured, we'll throw a more explanatory exception than method not found. // Wordpress API #region IWordPressApi Members public int newCategory(string blogid, string username, string password, WordpressCategory category) { var newCategory = new LinkCategory { CategoryType = CategoryType.PostCollection, Title = category.name, IsActive = true, Description = category.name }; newCategory.Id = Links.CreateLinkCategory(newCategory); return(newCategory.Id); }
static int[] CreateSomePostCategories() { var categoryIds = new int[3]; categoryIds[0] = Links.CreateLinkCategory(CreateCategory("My Favorite Feeds", "Some of my favorite RSS feeds", CategoryType.PostCollection, true)); categoryIds[1] = Links.CreateLinkCategory(CreateCategory("Google Blogs", "My favorite Google blogs", CategoryType.PostCollection, true)); categoryIds[2] = Links.CreateLinkCategory(CreateCategory("Microsoft Blogs", "My favorite Microsoft blogs", CategoryType.PostCollection, false)); return(categoryIds); }
public LinkCollectionTester() { var category = new LinkCategory { BlogId = Config.CurrentBlog.Id, IsActive = true, Title = "Foobar", Description = "Unit Test" }; _categoryId = Links.CreateLinkCategory(category); //Create a couple links that should be ignored because postId is not null. Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("Phil", "title", "in great shape"); int entryId = UnitTestHelper.Create(entry); UnitTestHelper.CreateLinkInDb(_categoryId, "A Forgettable Link", entryId, String.Empty); UnitTestHelper.CreateLinkInDb(_categoryId, "Another Forgettable Link", entryId, String.Empty); UnitTestHelper.CreateLinkInDb(_categoryId, "Another Forgettable Link", entryId, String.Empty); }
public void CanCreateAndDeleteLink() { UnitTestHelper.SetupBlog(); int categoryId = Links.CreateLinkCategory(CreateCategory("My Favorite Feeds", "Some of my favorite RSS feeds", CategoryType.LinkCollection, true)); Link link = CreateLink("Title", categoryId, null); int linkId = link.Id; Link loaded = ObjectProvider.Instance().GetLink(linkId); Assert.AreEqual("Title", loaded.Title); Assert.AreEqual(NullValue.NullInt32, loaded.PostId); Assert.AreEqual(Config.CurrentBlog.Id, loaded.BlogId); Links.DeleteLink(linkId); Assert.IsNull(ObjectProvider.Instance().GetLink(linkId)); }
// REFACTOR: duplicate from category editor; generalize a la EntryEditor private void PersistCategory(LinkCategory category) { try { if (category.Id > 0) { Repository.UpdateLinkCategory(category); Messages.ShowMessage(string.Format(CultureInfo.InvariantCulture, Resources.Message_CategoryUpdated, category.Title)); } else { category.Id = Links.CreateLinkCategory(category); Messages.ShowMessage(string.Format(CultureInfo.InvariantCulture, Resources.Message_CategoryAdded, category.Title)); } } catch (Exception ex) { Messages.ShowError(String.Format(Constants.RES_EXCEPTION, "TODO...", ex.Message)); } }
public void CanCreateAndDeleteLinkCategory() { UnitTestHelper.SetupBlog(); // Create some categories int categoryId = Links.CreateLinkCategory(CreateCategory("My Favorite Feeds", "Some of my favorite RSS feeds", CategoryType.LinkCollection, true)); LinkCategory category = ObjectProvider.Instance().GetLinkCategory(categoryId, true); Assert.AreEqual(Config.CurrentBlog.Id, category.BlogId); Assert.AreEqual("My Favorite Feeds", category.Title); Assert.AreEqual("Some of my favorite RSS feeds", category.Description); Assert.IsTrue(category.HasDescription); Assert.IsFalse(category.HasLinks); Assert.IsFalse(category.HasImages); Assert.IsTrue(category.IsActive); Assert.AreEqual(CategoryType.LinkCollection, category.CategoryType); Assert.IsNotNull(category); Links.DeleteLinkCategory(categoryId); Assert.IsNull(ObjectProvider.Instance().GetLinkCategory(categoryId, true)); }