public void CanUpdateMetaTag(string content, string name, string httpequiv) { var blog = UnitTestHelper.CreateBlogAndSetupContext(); MetaTag tag = UnitTestHelper.BuildMetaTag(content, name, httpequiv, blog.Id, null, DateTime.Now); MetaTags.Create(tag); string randomStr = UnitTestHelper.GenerateUniqueString().Left(20); tag.Content = content + randomStr; if (!string.IsNullOrEmpty(name)) { tag.Name = name + randomStr; } if (!string.IsNullOrEmpty(httpequiv)) { tag.HttpEquiv = httpequiv + randomStr; } Assert.IsTrue(MetaTags.Update(tag)); MetaTag updTag = MetaTags.GetMetaTagsForBlog(blog, 0, 100)[0]; ValidateMetaTags(tag, updTag); }
public void CanDeleteEntryMetaTag() { var blog = UnitTestHelper.CreateBlogAndSetupContext(); Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("Steven Harman", "Sweet arse entry!", "Giddy, giddy, goo!"); UnitTestHelper.Create(entry); MetaTag tag = UnitTestHelper.BuildMetaTag("Foo, bar, zaa?", "author", null, blog.Id, entry.Id, DateTime.Now); MetaTags.Create(tag); Assert.AreEqual(1, MetaTags.GetMetaTagsForBlog(blog, 0, 100).Count, "Should be one (1) MetaTag for this blog."); Assert.AreEqual(1, MetaTags.GetMetaTagsForEntry(entry, 0, 100).Count, "Should be one (1) MetaTag for this entry."); // Now let's remove it from the data store Assert.IsTrue(MetaTags.Delete(tag.Id), "Deleting the MetaTag failed."); Assert.AreEqual(0, MetaTags.GetMetaTagsForBlog(blog, 0, 100).Count, "Should be zero (0) MetaTags for this blog."); Assert.AreEqual(0, MetaTags.GetMetaTagsForEntry(entry, 0, 100).Count, "Should be zero (0) MetaTag for this entry."); }
public void Create(int index) { var tag = new MetaTag("test" + index) { DateCreated = DateTime.Now, Name = "foo", BlogId = Config.CurrentBlog.Id }; MetaTags.Create(tag); }
public MetaTag AddMetaTagForBlog(string content, string name, string httpEquiv) { var newTag = new MetaTag(content) { Name = name, HttpEquiv = httpEquiv, BlogId = Config.CurrentBlog.Id, DateCreated = DateTime.Now }; MetaTags.Create(newTag); return(newTag); }
public void CanRemoveHttpEquivAndAddName() { var blog = UnitTestHelper.CreateBlogAndSetupContext(); MetaTag tag = UnitTestHelper.BuildMetaTag("Still nothing to see here.", null, "expires", blog.Id, null, DateTime.Now); MetaTags.Create(tag); tag.HttpEquiv = null; tag.Name = "author"; tag.Content = "Steve-o-rino!"; MetaTags.Update(tag); ValidateMetaTags(tag, MetaTags.GetMetaTagsForBlog(blog, 0, 100)[0]); }
public void CanRemoveNameAndAddHttpEquiv() { var blog = UnitTestHelper.CreateBlogAndSetupContext(); MetaTag tag = UnitTestHelper.BuildMetaTag("Nothing to see here.", "description", null, blog.Id, null, DateTime.Now); MetaTags.Create(tag); tag.HttpEquiv = "cache-control"; tag.Name = null; tag.Content = "no-cache"; MetaTags.Update(tag); ValidateMetaTags(tag, MetaTags.GetMetaTagsForBlog(blog, 0, 100)[0]); }
public void CanDeleteBlogMetaTag() { var blog = UnitTestHelper.CreateBlogAndSetupContext(); MetaTag tag = UnitTestHelper.BuildMetaTag("Steve Harman likes to delete stuff!", "description", null, blog.Id, null, DateTime.Now); MetaTags.Create(tag); Assert.AreEqual(1, MetaTags.GetMetaTagsForBlog(blog, 0, 100).Count, "Should be one (1) MetaTag for this blog."); // Now let's remove it from the data store Assert.IsTrue(MetaTags.Delete(tag.Id), "Deleting the MetaTag failed."); Assert.AreEqual(0, MetaTags.GetMetaTagsForBlog(blog, 0, 100).Count, "Should be zero (0) MetaTags for this blog."); }
public void CanInsertNewMetaTag(string content, string name, string httpEquiv, bool withEntry, string errMsg) { blog = UnitTestHelper.CreateBlogAndSetupContext(); int?entryId = null; if (withEntry) { Entry e = UnitTestHelper.CreateEntryInstanceForSyndication("Steven Harman", "My Post", "Foo Bar Zaa!"); entryId = UnitTestHelper.Create(e); } MetaTag mt = UnitTestHelper.BuildMetaTag(content, name, httpEquiv, blog.Id, entryId, DateTime.Now); // make sure there are no meta-tags for this blog in the data store ICollection <MetaTag> tags = MetaTags.GetMetaTagsForBlog(blog, 0, 100); Assert.AreEqual(0, tags.Count, "Should be zero MetaTags."); // add the meta-tag to the data store int tagId = MetaTags.Create(mt); tags = MetaTags.GetMetaTagsForBlog(blog, 0, 100); Assert.AreEqual(1, tags.Count, errMsg); MetaTag newTag = tags.First(); // make sure all attributes of the meta-tag were written to the data store correctly. Assert.AreEqual(tagId, newTag.Id, "Wrong Id"); Assert.AreEqual(mt.Content, newTag.Content, "Wrong content"); Assert.AreEqual(mt.Name, newTag.Name, "wrong name attribute"); Assert.AreEqual(mt.HttpEquiv, newTag.HttpEquiv, "Wrong http-equiv attriubte"); Assert.AreEqual(mt.BlogId, newTag.BlogId, "Wrong blogId"); Assert.AreEqual(mt.EntryId, newTag.EntryId, "Wrong entryId"); Assert.AreEqual(mt.DateCreated.Date, newTag.DateCreated.Date, "Wrong created date"); }
public void CanNotInsertNullMetaTag() { UnitTestHelper.AssertThrowsArgumentNullException(() => MetaTags.Create(null)); }
public void Create_WithInvalidMetaTag_ThrowsArgumentException() { UnitTestHelper.AssertThrows <ArgumentException>(() => MetaTags.Create(new MetaTag { Content = null })); }
public void Create_WithNullMetaTag_ThrowsArgumentNullException() { UnitTestHelper.AssertThrowsArgumentNullException(() => MetaTags.Create(null)); }