public GetMetaTagsForBlog ( BlogInfo blog, int pageIndex, int pageSize ) : IPagedCollection |
||
blog | BlogInfo | |
pageIndex | int | |
pageSize | int | |
return | IPagedCollection |
public void CanInsertNewMetaTag(string content, string name, string httpEquiv, bool withEntry, string errMsg) { blog = UnitTestHelper.CreateBlogAndSetupContext(); var repository = new DatabaseObjectProvider(); 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.UtcNow); // make sure there are no meta-tags for this blog in the data store ICollection<MetaTag> tags = repository.GetMetaTagsForBlog(blog, 0, 100); Assert.AreEqual(0, tags.Count, "Should be zero MetaTags."); // add the meta-tag to the data store int tagId = repository.Create(mt); tags = repository.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.DateCreatedUtc.Date, newTag.DateCreatedUtc.Date, "Wrong created date"); }
public void CanDeleteEntryMetaTag() { var blog = UnitTestHelper.CreateBlogAndSetupContext(); var repository = new DatabaseObjectProvider(); 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.UtcNow); repository.Create(tag); Assert.AreEqual(1, repository.GetMetaTagsForBlog(blog, 0, 100).Count, "Should be one (1) MetaTag for this blog."); Assert.AreEqual(1, repository.GetMetaTagsForEntry(entry, 0, 100).Count, "Should be one (1) MetaTag for this entry."); // Now let's remove it from the data store Assert.IsTrue(repository.DeleteMetaTag(tag.Id), "Deleting the MetaTag failed."); Assert.AreEqual(0, repository.GetMetaTagsForBlog(blog, 0, 100).Count, "Should be zero (0) MetaTags for this blog."); Assert.AreEqual(0, repository.GetMetaTagsForEntry(entry, 0, 100).Count, "Should be zero (0) MetaTag for this entry."); }
public void CanDeleteBlogMetaTag() { var blog = UnitTestHelper.CreateBlogAndSetupContext(); var repository = new DatabaseObjectProvider(); MetaTag tag = UnitTestHelper.BuildMetaTag("Steve Harman likes to delete stuff!", "description", null, blog.Id, null, DateTime.UtcNow); repository.Create(tag); Assert.AreEqual(1, repository.GetMetaTagsForBlog(blog, 0, 100).Count, "Should be one (1) MetaTag for this blog."); // Now let's remove it from the data store Assert.IsTrue(repository.DeleteMetaTag(tag.Id), "Deleting the MetaTag failed."); Assert.AreEqual(0, repository.GetMetaTagsForBlog(blog, 0, 100).Count, "Should be zero (0) MetaTags for this blog."); }
public void CanGetMetaTagsForBlog() { blog = UnitTestHelper.CreateBlogAndSetupContext(); var repository = new DatabaseObjectProvider(); InsertNewMetaTag("Adding description meta tag", "description", null, DateTime.UtcNow, blog.Id, null); InsertNewMetaTag("no-cache", null, "cache-control", DateTime.UtcNow, blog.Id, null); ICollection<MetaTag> tags = repository.GetMetaTagsForBlog(blog, 0, 100); Assert.AreEqual(2, tags.Count, "Should be two tags for this blog."); }
public void CanRemoveHttpEquivAndAddName() { var blog = UnitTestHelper.CreateBlogAndSetupContext(); var repository = new DatabaseObjectProvider(); MetaTag tag = UnitTestHelper.BuildMetaTag("Still nothing to see here.", null, "expires", blog.Id, null, DateTime.UtcNow); repository.Create(tag); tag.HttpEquiv = null; tag.Name = "author"; tag.Content = "Steve-o-rino!"; repository.Update(tag); ValidateMetaTags(tag, repository.GetMetaTagsForBlog(blog, 0, 100)[0]); }
public void CanRemoveNameAndAddHttpEquiv() { var blog = UnitTestHelper.CreateBlogAndSetupContext(); var repository = new DatabaseObjectProvider(); MetaTag tag = UnitTestHelper.BuildMetaTag("Nothing to see here.", "description", null, blog.Id, null, DateTime.UtcNow); repository.Create(tag); tag.HttpEquiv = "cache-control"; tag.Name = null; tag.Content = "no-cache"; repository.Update(tag); ValidateMetaTags(tag, repository.GetMetaTagsForBlog(blog, 0, 100)[0]); }
public void GetReturnsZeroWhenNoMetaTagsExistForBlog() { var repository = new DatabaseObjectProvider(); blog = UnitTestHelper.CreateBlogAndSetupContext(); Assert.AreEqual(0, repository.GetMetaTagsForBlog(blog, 0, 100).Count, "Shouldn't have found any MetaTags for this blog."); }
public void CanUpdateMetaTag(string content, string name, string httpequiv) { var blog = UnitTestHelper.CreateBlogAndSetupContext(); var repository = new DatabaseObjectProvider(); MetaTag tag = UnitTestHelper.BuildMetaTag(content, name, httpequiv, blog.Id, null, DateTime.UtcNow); repository.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(repository.Update(tag)); MetaTag updTag = repository.GetMetaTagsForBlog(blog, 0, 100)[0]; ValidateMetaTags(tag, updTag); }