Exemplo n.º 1
0
        public virtual void MakeSortedCommentsList_InOrder()
        {
            using (new SecurityDisabler())
            {
                m_testRoot.Paste(File.ReadAllText(HttpContext.Current.Server.MapPath(@"~\test data\comments in order.xml")), false, PasteMode.Overwrite);
            }

            var commentFolder = m_testRoot.Axes.GetChild("comments in order");

            try
            {
                var sorted = new Mod.CommentManager().MakeSortedCommentsList(commentFolder.Axes.GetDescendants().Where(i => i.TemplateID.ToString() == m_commentTemplateId).ToArray());
                Assert.AreEqual(3, sorted.Length);
                Assert.AreEqual("Comment1", sorted[0].InnerItem.Name);
                Assert.AreEqual("Comment2", sorted[1].InnerItem.Name);
                Assert.AreEqual("Comment3", sorted[2].InnerItem.Name);
            }
            finally
            {
                if (commentFolder != null)
                {
                    using (new SecurityDisabler())
                    {
                        commentFolder.Delete();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void GetCommentCount_Medium()
        {
            var entry        = m_mediumTree.Axes.GetDescendant("Entry" + MEDIUM_SPECIFIC_ENTRY.ToString());
            var commentCount = new Mod.CommentManager().GetCommentsCount(entry);

            Assert.AreEqual(m_mediumTreeCommentCountForEntry, commentCount);
        }
Exemplo n.º 3
0
        public void GetBlogComments_NullItem_ReturnsEmptyList()
        {
            var manager  = new Mod.CommentManager(null, null, null, null);
            var comments = manager.GetBlogComments(null, 10);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 4
0
        public void GetCommentsByBlog_Medium()
        {
            //System.Threading.Thread.Sleep(5000);
            var comments = new Mod.CommentManager().GetCommentsByBlog(m_mediumTree, int.MaxValue);

            Assert.AreEqual(m_mediumTreeCommentCount, comments.Length);
        }
Exemplo n.º 5
0
        public void GetCommentCount_Small()
        {
            var entry        = m_smallTree.Axes.GetDescendant("Entry" + SMALL_SPECIFIC_ENTRY.ToString());
            var commentCount = new Mod.CommentManager().GetCommentsCount(entry);

            Assert.AreEqual(m_smallTreeCommentCountForEntry, commentCount);
        }
Exemplo n.º 6
0
        public void GetEntryComments_NullItem()
        {
            var manager  = new Mod.CommentManager(null, null, null, null);
            var comments = manager.GetEntryComments((Item)null, 10);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 7
0
        public void GetCommentsByBlog_NullItem()
        {
            var manager  = new Mod.CommentManager();
            var comments = manager.GetCommentsByBlog(null, 10);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 8
0
        public void GetCommentsCount_NullItem()
        {
            var manager = new Mod.CommentManager(null, null, null, null);
            var count   = manager.GetCommentsCount((Item)null);

            Assert.That(count, Is.EqualTo(0));
        }
Exemplo n.º 9
0
        public void GetCommentsFor_NullItem()
        {
            var manager = new Mod.CommentManager();
            var entries = manager.GetCommentsFor(null, 10);

            Assert.That(entries, Is.Empty);
        }
Exemplo n.º 10
0
        public void GetCommentCount_Large()
        {
            var entry        = m_largeTree.Axes.GetDescendant("Entry" + LARGE_SPECIFIC_ENTRY.ToString());
            var commentCount = new Mod.CommentManager().GetCommentsCount(entry);

            Assert.AreEqual(m_largeTreeCommentCountForEntry, commentCount);
        }
Exemplo n.º 11
0
        public void AddCommentToEntry_WithLanguage()
        {
            // Perform this test in master DB as comments get created there
            var db = Sitecore.Configuration.Factory.GetDatabase("master");

            ID germanCommentId = null;

            try
            {
                var germanComment = new Sitecore.Modules.WeBlog.Model.Comment()
                {
                    AuthorEmail = "*****@*****.**",
                    AuthorName  = "german commentor",
                    Text        = "My German Comment"
                };

                germanComment.Fields[Sitecore.Modules.WeBlog.Constants.Fields.IpAddress] = "127.0.0.1";
                germanComment.Fields[Sitecore.Modules.WeBlog.Constants.Fields.Website]   = "website";

                var language = Sitecore.Globalization.Language.Parse("de");

                germanCommentId = new Mod.CommentManager().AddCommentToEntry(m_entry12.ID, germanComment, language);

                var germanCommentItem = db.GetItem(germanCommentId, language);
                Assert.IsNotNull(germanCommentItem);

                // Ensure the item only contains a version in German
                Assert.AreEqual(1, germanCommentItem.Versions.Count);
                Assert.AreEqual("de", germanCommentItem.Versions[new Sitecore.Data.Version(1)].Language.Name);
            }
            finally
            {
                var webDb = Sitecore.Configuration.Factory.GetDatabase("web");

                if (germanCommentId != (ID)null)
                {
                    var commentItem = db.GetItem(germanCommentId);
                    if (commentItem != null)
                    {
                        using (new SecurityDisabler())
                        {
                            commentItem.Delete();
                        }
                    }

                    commentItem = webDb.GetItem(germanCommentId);
                    if (commentItem != null)
                    {
                        using (new SecurityDisabler())
                        {
                            commentItem.Delete();
                        }
                    }
                }

                RebuildIndex();
            }
        }
Exemplo n.º 12
0
        public void GetEntryComments_WithLanguage_Entry11()
        {
            var comments = new Mod.CommentManager().GetEntryComments(m_deComment111);

            Assert.AreEqual(1, comments.Length);

            var ids = (from comment in comments
                       select comment.ID).ToArray();
        }
Exemplo n.º 13
0
        public void GetEntryComments_Entry11_WithLimit()
        {
            var comments = new Mod.CommentManager().GetEntryComments(m_entry11, 2);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
                m_comment113.ID,
                m_comment112.ID
            }));
        }
Exemplo n.º 14
0
        public void GetEntryComments_Entry21()
        {
            var comments = new Mod.CommentManager().GetEntryComments(m_entry21);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
                m_comment211.ID,
                m_comment212.ID
            }));
        }
Exemplo n.º 15
0
        public void GetEntryComments_WithLanguage_Entry11()
        {
            var deEntry  = m_entry11.Database.GetItem(m_entry11.ID, Language.Parse("de"));
            var comments = new Mod.CommentManager().GetEntryComments(deEntry);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
                m_deComment111.ID
            }));
        }
Exemplo n.º 16
0
        public void GetCommentsByBlog_Blog2_NoLimit()
        {
            var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog2, int.MaxValue);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
                m_comment211.ID,
                m_comment212.ID
            }));
        }
Exemplo n.º 17
0
        public void GetCommentsByBlog_Blog1_Limited_ById()
        {
            var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog1.ID, 4);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
                m_comment122.ID,
                m_comment121.ID,
                m_comment113.ID,
                m_comment112.ID
            }));
        }
Exemplo n.º 18
0
        public void GetEntryComments_EntryWithoutComments()
        {
            var blog      = TestUtil.CreateNewBlog(TestContentRoot);
            var entryLuna = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));

            TestUtil.UpdateIndex();

            var manager  = new Mod.CommentManager(null, null, null, null);
            var comments = manager.GetEntryComments(entryLuna, 10);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 19
0
        public void GetCommentsByBlog_Blog2_NoLimit()
        {
            var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog2, int.MaxValue);

            Assert.AreEqual(2, comments.Length);

            var ids = (from comment in comments
                       select comment.ID).ToArray();

            Assert.Contains(m_comment211.ID, ids);
            Assert.Contains(m_comment212.ID, ids);
        }
Exemplo n.º 20
0
        public void GetCommentsCount_EntryWithoutComments()
        {
            var blog      = TestUtil.CreateNewBlog(TestContentRoot);
            var entryLuna = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));

            TestUtil.UpdateIndex();

            var manager = new Mod.CommentManager(null, null, null, null);
            var count   = manager.GetCommentsCount(entryLuna);

            Assert.That(count, Is.EqualTo(0));
        }
Exemplo n.º 21
0
        public void GetEntryComments_Entry11_WithLimit()
        {
            var comments = new Mod.CommentManager().GetEntryComments(m_entry11, 2);

            Assert.AreEqual(2, comments.Length);

            var ids = (from comment in comments
                       select comment.ID).ToArray();

            Assert.Contains(m_comment111.ID, ids);
            Assert.Contains(m_comment112.ID, ids);
        }
Exemplo n.º 22
0
        public void GetBlogComments_NoComments_ReturnsEmptyList()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna   = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));
            var entryDeimos = TestUtil.CreateNewEntry(blog, "Deimos", entryDate: new DateTime(2012, 3, 2));

            TestUtil.UpdateIndex();

            var manager  = new Mod.CommentManager(null, null, null, null);
            var comments = manager.GetBlogComments(blog, 10);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 23
0
        public void GetCommentsByBlog_Blog1_Limited_ById()
        {
            var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog1.ID, 4);

            Assert.AreEqual(4, comments.Length);

            var ids = (from comment in comments
                       select comment.ID).ToArray();

            Assert.Contains(m_comment122.ID, ids);
            Assert.Contains(m_comment121.ID, ids);
            Assert.Contains(m_comment113.ID, ids);
            Assert.Contains(m_comment112.ID, ids);
        }
Exemplo n.º 24
0
        public void GetCommentsCount_NonEntry()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna   = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));
            var commetLuna1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 2));
            var commetLuna2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 3));

            TestUtil.UpdateIndex();

            var manager = new Mod.CommentManager();
            var count   = manager.GetCommentsCount(blog);

            Assert.That(count, Is.EqualTo(0));
        }
Exemplo n.º 25
0
        public void GetEntryComments_EntryWithComments()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna   = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));
            var commetLuna1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 2));
            var commetLuna2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 4));

            TestUtil.UpdateIndex();

            var manager  = new Mod.CommentManager(null, null, null, null);
            var comments = manager.GetEntryComments(entryLuna, 10);
            var ids      = from comment in comments select comment.Uri.ItemID;

            Assert.That(ids, Is.EqualTo(new[] { commetLuna1.ID, commetLuna2.ID }));
        }
Exemplo n.º 26
0
        public void GetCommentsFor_EntryWithComments_Sorted()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna   = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));
            var commetLuna1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 4));
            var commetLuna2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 6));

            var entryDeimos    = TestUtil.CreateNewEntry(blog, "Deimos", entryDate: new DateTime(2012, 3, 2));
            var commentDeimos1 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 7));
            var commentDeimos2 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 8));

            TestUtil.UpdateIndex();

            var manager  = new Mod.CommentManager();
            var comments = manager.GetCommentsFor(blog, 10, true);
            var ids      = from comment in comments select comment.ID;

            Assert.That(ids, Is.EqualTo(new[] { commetLuna1.ID, commetLuna2.ID, commentDeimos1.ID, commentDeimos2.ID }));
        }
Exemplo n.º 27
0
        public void GetCommentsByBlog_CommentsInBlog_Limited()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));
            var lunaComment1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 1));
            var lunaComment2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 2));

            var entryDeimos = TestUtil.CreateNewEntry(blog, "Deimos", entryDate: new DateTime(2012, 3, 2));
            var deimosComment1 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 3));
            var deimosComment2 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 4));

            TestUtil.UpdateIndex();

            var manager = new Mod.CommentManager();
            var comments = manager.GetCommentsByBlog(blog, 3);
            var ids = from comment in comments select comment.ID;

            Assert.That(ids, Is.EqualTo(new[] { deimosComment2.ID, deimosComment1.ID, lunaComment2.ID }));
        }
Exemplo n.º 28
0
        public void GetBlogComments_Limited_ReturnsStartOfList()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna    = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));
            var lunaComment1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 1));
            var lunaComment2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 2));

            var entryDeimos    = TestUtil.CreateNewEntry(blog, "Deimos", entryDate: new DateTime(2012, 3, 2));
            var deimosComment1 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 3));
            var deimosComment2 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 4));

            TestUtil.UpdateIndex();

            var manager  = new Mod.CommentManager(null, null, null, null);
            var comments = manager.GetBlogComments(blog, 3);
            var ids      = from comment in comments select comment.Uri.ItemID;

            Assert.That(ids, Is.EqualTo(new[] { deimosComment2.ID, deimosComment1.ID, lunaComment2.ID }));
        }
Exemplo n.º 29
0
        public void GetCommentsFor_EntryWithoutComments()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna   = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));
            var commetLuna1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 1));
            var commetLuna2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 3));

            var entryDeimos    = TestUtil.CreateNewEntry(blog, "Deimos", entryDate: new DateTime(2012, 3, 2));
            var commentDeimos1 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 5));
            var commentDeimos2 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 6));

            var entryPhobos = TestUtil.CreateNewEntry(blog, "Phobos", entryDate: new DateTime(2012, 3, 3));

            TestUtil.UpdateIndex();

            var manager  = new Mod.CommentManager();
            var comments = manager.GetCommentsFor(entryPhobos, 10);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 30
0
        public void GetCommentsByBlog_CommentsInBlog()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));

            var lunaComment1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2013, 4, 5));
            var lunaComment2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2013, 4, 8));

            var entryDeimos    = TestUtil.CreateNewEntry(blog, "Deimos", entryDate: new DateTime(2012, 3, 2));
            var deimosComment1 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2013, 4, 9));
            var deimosComment2 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2013, 4, 10));

            TestUtil.UpdateIndex();

            var manager  = new Mod.CommentManager();
            var comments = manager.GetCommentsByBlog(blog, 10);
            var ids      = from comment in comments select comment.ID;

            Assert.That(ids, Is.EqualTo(new[] { deimosComment2.ID, deimosComment1.ID, lunaComment2.ID, lunaComment1.ID }));
        }
Exemplo n.º 31
0
        public void GetBlogComments_CommentsInOtherBlog_ReturnsEmptyList()
        {
            var blog1 = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna    = TestUtil.CreateNewEntry(blog1, "Luna", entryDate: new DateTime(2012, 3, 1));
            var lunaComment1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 1));
            var lunaComment2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 2));

            var entryDeimos    = TestUtil.CreateNewEntry(blog1, "Deimos", entryDate: new DateTime(2012, 3, 2));
            var deimosComment1 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 3));
            var deimosComment2 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 10));

            var blog2 = TestUtil.CreateNewBlog(TestContentRoot);

            TestUtil.UpdateIndex();

            var manager  = new Mod.CommentManager(null, null, null, null);
            var comments = manager.GetBlogComments(blog2, 3);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 32
0
        public void GetCommentsByBlog_CommentsInManyBlogs()
        {
            var blog1 = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna = TestUtil.CreateNewEntry(blog1, "Luna", entryDate: new DateTime(2012, 3, 1));
            var lunaComment1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 1));

            var entryDeimos = TestUtil.CreateNewEntry(blog1, "Deimos", entryDate: new DateTime(2012, 3, 2));

            var blog2 = TestUtil.CreateNewBlog(TestContentRoot);

            var entryAlpha = TestUtil.CreateNewEntry(blog2, "alpha", entryDate: new DateTime(2012, 3, 1));
            TestUtil.CreateNewComment(entryAlpha, new DateTime(2012, 3, 2));
            TestUtil.CreateNewComment(entryAlpha, new DateTime(2012, 3, 3));

            TestUtil.UpdateIndex();

            var manager = new Mod.CommentManager();
            var comments = manager.GetCommentsByBlog(blog1, 3);
            var ids = from comment in comments select comment.ID;

            Assert.That(ids, Is.EqualTo(new[] { lunaComment1.ID }));
        }
Exemplo n.º 33
0
        public void GetEntryComments_NullItem()
        {
            var manager = new Mod.CommentManager();
            var comments = manager.GetEntryComments((Item)null);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 34
0
        public void GetEntryComments_WithLanguage_Entry11()
        {
            var deEntry = m_entry11.Database.GetItem(m_entry11.ID, Language.Parse("de"));
            var comments = new Mod.CommentManager().GetEntryComments(deEntry);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
              m_deComment111.ID
            }));
        }
Exemplo n.º 35
0
        public void GetCommentsByBlog_Blog1_Limited_ById()
        {
            var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog1.ID, 4);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
              m_comment122.ID,
              m_comment121.ID,
              m_comment113.ID,
              m_comment112.ID
            }));
        }
Exemplo n.º 36
0
        public void GetCommentsByBlog_CommentsInOtherBlog()
        {
            var blog1 = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna = TestUtil.CreateNewEntry(blog1, "Luna", entryDate: new DateTime(2012, 3, 1));
            var lunaComment1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 1));
            var lunaComment2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 2));

            var entryDeimos = TestUtil.CreateNewEntry(blog1, "Deimos", entryDate: new DateTime(2012, 3, 2));
            var deimosComment1 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 3));
            var deimosComment2 = TestUtil.CreateNewComment(entryDeimos, new DateTime(2012, 3, 10));

            var blog2 = TestUtil.CreateNewBlog(TestContentRoot);

            TestUtil.UpdateIndex();

            var manager = new Mod.CommentManager();
            var comments = manager.GetCommentsByBlog(blog2, 3);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 37
0
        public void GetEntryComments_Entry21()
        {
            var comments = new Mod.CommentManager().GetEntryComments(m_entry21);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
                m_comment211.ID,
                m_comment212.ID
            }));
        }
Exemplo n.º 38
0
        public void GetEntryComments_WithLanguage_Entry11()
        {
            var comments = new Mod.CommentManager().GetEntryComments(m_deComment111);
            Assert.AreEqual(1, comments.Length);

            var ids = (from comment in comments
                       select comment.ID).ToArray();
        }
Exemplo n.º 39
0
        public void GetEntryComments_Entry21()
        {
            var comments = new Mod.CommentManager().GetEntryComments(m_entry21);
            Assert.AreEqual(2, comments.Length);

            var ids = (from comment in comments
                       select comment.ID).ToArray();

            Assert.Contains(m_comment211.ID, ids);
            Assert.Contains(m_comment212.ID, ids);
        }
Exemplo n.º 40
0
 public void GetEntryComments_Entry11_LimitZero()
 {
     var comments = new Mod.CommentManager().GetEntryComments(m_entry11, 0);
     Assert.AreEqual(0, comments.Length);
 }
Exemplo n.º 41
0
        public void GetCommentsByBlog_Blog2_NoLimit()
        {
            var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog2, int.MaxValue);
            Assert.AreEqual(2, comments.Length);

            var ids = (from comment in comments
                       select comment.ID).ToArray();

            Assert.Contains(m_comment211.ID, ids);
            Assert.Contains(m_comment212.ID, ids);
        }
Exemplo n.º 42
0
 public void GetCommentsByBlog_Blog1_LimitZero()
 {
     var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog1.ID, 0);
     Assert.AreEqual(0, comments.Length);
 }
Exemplo n.º 43
0
        public void AddCommentToEntry_WithLanguage()
        {
            // Perform this test in master DB as comments get created there
            var db = Sitecore.Configuration.Factory.GetDatabase("master");

            ID germanCommentId = null;

            try
            {
                var germanComment = new Sitecore.Modules.WeBlog.Model.Comment()
                {
                    AuthorEmail = "*****@*****.**",
                    AuthorName = "german commentor",
                    Text = "My German Comment"
                };

                germanComment.Fields[Sitecore.Modules.WeBlog.Constants.Fields.IpAddress] = "127.0.0.1";
                germanComment.Fields[Sitecore.Modules.WeBlog.Constants.Fields.Website] = "website";

                germanCommentId = new Mod.CommentManager().AddCommentToEntry(m_entry12.ID, germanComment, Sitecore.Globalization.Language.Parse("de"));

                var germanCommentItem = db.GetItem(germanCommentId);
                Assert.IsNotNull(germanCommentItem);

                // Ensure the item only contains a version in German
                Assert.AreEqual(1, germanCommentItem.Versions.Count);
                Assert.AreEqual("de", germanCommentItem.Versions[new Sitecore.Data.Version(1)].Language.Name);
            }
            finally
            {
                var webDb = Sitecore.Configuration.Factory.GetDatabase("web");

                if (germanCommentId != (ID)null)
                {
                    var commentItem = db.GetItem(germanCommentId);
                    if (commentItem != null)
                    {
                        using (new SecurityDisabler())
                        {
                            commentItem.Delete();
                        }
                    }

                    commentItem = webDb.GetItem(germanCommentId);
                    if (commentItem != null)
                    {
                        using (new SecurityDisabler())
                        {
                            commentItem.Delete();
                        }
                    }
                }
            }
        }
Exemplo n.º 44
0
        public void GetCommentsByBlog_Blog2_NoLimit()
        {
            var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog2, int.MaxValue);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
              m_comment211.ID,
              m_comment212.ID
            }));
        }
Exemplo n.º 45
0
        public virtual void MakeSortedCommentsList_WithNonComment()
        {
            Item commentFolder = null;

            using (new SecurityDisabler())
            {
                m_testRoot.Paste(File.ReadAllText(HttpContext.Current.Server.MapPath(@"~\test data\comments in order.xml")), false, PasteMode.Overwrite);
                commentFolder = m_testRoot.Axes.GetChild("comments in order");

                var folderTemplate = Sitecore.Context.Database.GetTemplate(FOLDER_TEMPLATE);
                commentFolder.Add("non comment", folderTemplate);
            }

            try
            {
                var sorted = new Mod.CommentManager().MakeSortedCommentsList(commentFolder.Axes.GetDescendants().Where(i => i.TemplateID.ToString() == m_commentTemplateId).ToArray());
                Assert.AreEqual(3, sorted.Length);
                Assert.AreEqual("Comment1", sorted[0].InnerItem.Name);
                Assert.AreEqual("Comment2", sorted[1].InnerItem.Name);
                Assert.AreEqual("Comment3", sorted[2].InnerItem.Name);
            }
            finally
            {
                if (commentFolder != null)
                {
                    using (new SecurityDisabler())
                    {
                        commentFolder.Delete();
                    }
                }
            }
        }
Exemplo n.º 46
0
        public void GetEntryComments_NonEntry()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));
            var commetLuna1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 3));
            var commetLuna2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 4));

            TestUtil.UpdateIndex();

            var manager = new Mod.CommentManager();
            var comments = manager.GetEntryComments(blog);

            Assert.That(comments, Is.Empty);
        }
Exemplo n.º 47
0
        public void GetCommentsByBlog_Blog1_Limited_ById()
        {
            var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog1.ID, 4);
            Assert.AreEqual(4, comments.Length);

            var ids = (from comment in comments
                       select comment.ID).ToArray();

            Assert.Contains(m_comment122.ID, ids);
            Assert.Contains(m_comment121.ID, ids);
            Assert.Contains(m_comment113.ID, ids);
            Assert.Contains(m_comment112.ID, ids);
        }
Exemplo n.º 48
0
 public void GetCommentsByBlog_Medium()
 {
     //System.Threading.Thread.Sleep(5000);
     var comments = new Mod.CommentManager().GetCommentsByBlog(m_mediumTree, int.MaxValue);
     Assert.AreEqual(m_mediumTreeCommentCount, comments.Length);
 }
Exemplo n.º 49
0
 public void GetCommentsByBlog_Blog1_NegativeLimit()
 {
     var comments = new Mod.CommentManager().GetCommentsByBlog(m_blog1.ID, -7);
     Assert.AreEqual(0, comments.Length);
 }
Exemplo n.º 50
0
 public void GetCommentsByBlog_Small()
 {
     var comments = new Mod.CommentManager().GetCommentsByBlog(m_smallTree, int.MaxValue);
     Assert.AreEqual(m_smallTreeCommentCount, comments.Length);
 }
Exemplo n.º 51
0
 public void GetEntryComments_BlogItem()
 {
     var comments = new Mod.CommentManager().GetEntryComments(m_blog1);
     Assert.AreEqual(0, comments.Length);
 }
Exemplo n.º 52
0
 public void GetCommentCount_Large()
 {
     var entry = m_largeTree.Axes.GetDescendant("Entry" + LARGE_SPECIFIC_ENTRY.ToString());
     var commentCount = new Mod.CommentManager().GetCommentsCount(entry);
     Assert.AreEqual(m_largeTreeCommentCountForEntry, commentCount);
 }
Exemplo n.º 53
0
 public void GetEntryComments_Entry11_NegativeLimit()
 {
     var comments = new Mod.CommentManager().GetEntryComments(m_entry11, -4);
     Assert.AreEqual(0, comments.Length);
 }
Exemplo n.º 54
0
 public void GetCommentCount_Medium()
 {
     var entry = m_mediumTree.Axes.GetDescendant("Entry" + MEDIUM_SPECIFIC_ENTRY.ToString());
     var commentCount = new Mod.CommentManager().GetCommentsCount(entry);
     Assert.AreEqual(m_mediumTreeCommentCountForEntry, commentCount);
 }
Exemplo n.º 55
0
 public void GetEntryComments_Null()
 {
     var comments = new Mod.CommentManager().GetEntryComments((Item)null);
     Assert.AreEqual(0, comments.Length);
 }
Exemplo n.º 56
0
 public void GetCommentForEntry_Small()
 {
     var entry = m_smallTree.Axes.GetDescendant("Entry" + SMALL_SPECIFIC_ENTRY.ToString());
     var comments = new Mod.CommentManager().GetEntryComments(entry);
     Assert.AreEqual(m_smallTreeCommentCountForEntry, comments.Length);
 }
Exemplo n.º 57
0
        public virtual void MakeSortedCommentsList_ReverseOrder()
        {
            using (new SecurityDisabler())
            {
                m_testRoot.Paste(File.ReadAllText(HttpContext.Current.Server.MapPath(@"~\test data\comments reverse order.xml")), false, PasteMode.Overwrite);
            }

            var commentFolder = m_testRoot.Axes.GetChild("comments reverse order");

            try
            {
                var sorted = new Mod.CommentManager().MakeSortedCommentsList(commentFolder.Axes.GetDescendants().Where(i => i.TemplateID.ToString() == m_commentTemplateId).ToArray());
                Assert.AreEqual(3, sorted.Length);
                Assert.AreEqual("Comment3", sorted[0].InnerItem.Name);
                Assert.AreEqual("Comment2", sorted[1].InnerItem.Name);
                Assert.AreEqual("Comment1", sorted[2].InnerItem.Name);
            }
            finally
            {
                if (commentFolder != null)
                {
                    using (new SecurityDisabler())
                    {
                        commentFolder.Delete();
                    }
                }
            }
        }
Exemplo n.º 58
0
        public void GetEntryComments_Entry11_WithLimit()
        {
            var comments = new Mod.CommentManager().GetEntryComments(m_entry11, 2);

            Assert.That(comments.Select(x => x.ID), Is.EquivalentTo(new[]
            {
                m_comment113.ID,
                m_comment112.ID
            }));
        }
Exemplo n.º 59
0
        public void AddCommentToEntry()
        {
            // Perform this test in master DB as comments get created there
            var db = Sitecore.Configuration.Factory.GetDatabase("master");
            var blogSettings = new BlogHomeItem(m_blog1).BlogSettings;

            var originalCount = m_entry12.Axes.GetDescendants().Count(i => i.TemplateID == blogSettings.CommentTemplateID);
            ID commentId = null;

            try
            {
                var comment = new Sitecore.Modules.WeBlog.Model.Comment()
                {
                    AuthorEmail = "*****@*****.**",
                    AuthorName = "commentor",
                    Text = "My Comment"
                };

                comment.Fields[Sitecore.Modules.WeBlog.Constants.Fields.IpAddress] = "127.0.0.1";
                comment.Fields[Sitecore.Modules.WeBlog.Constants.Fields.Website] = "website";

                commentId = new Mod.CommentManager().AddCommentToEntry(m_entry12.ID, comment);
                var childCount = m_entry12.Axes.GetDescendants().Count(i => i.TemplateID == blogSettings.CommentTemplateID);

                Assert.IsTrue(commentId != ID.Null);
                Assert.AreEqual(originalCount + 1, childCount);

                var commentItem = db.GetItem(commentId);
                Assert.IsNotNull(commentItem);

                var commentAsComment = new Sitecore.Modules.WeBlog.Items.WeBlog.CommentItem(commentItem);
                Assert.AreEqual("*****@*****.**", commentAsComment.Email.Text);
                Assert.AreEqual("commentor", commentAsComment.Name.Text);
                Assert.AreEqual("127.0.0.1", commentAsComment.IPAddress.Text);
                Assert.AreEqual("website", commentAsComment.Website.Text);
                Assert.AreEqual("My Comment", StringUtil.RemoveTags(commentAsComment.Comment.Text));
            }
            finally
            {
                var webDb = Sitecore.Configuration.Factory.GetDatabase("web");
                if (commentId != (ID)null)
                {
                    var commentItem = db.GetItem(commentId);
                    if (commentItem != null)
                    {
                        using (new SecurityDisabler())
                        {
                            commentItem.Delete();
                        }
                    }

                    commentItem = webDb.GetItem(commentId);
                    if (commentItem != null)
                    {
                        using (new SecurityDisabler())
                        {
                            commentItem.Delete();
                        }
                    }
                }
            }
        }
Exemplo n.º 60
0
        public void GetEntryComments_EntryWithComments_Limited()
        {
            var blog = TestUtil.CreateNewBlog(TestContentRoot);

            var entryLuna = TestUtil.CreateNewEntry(blog, "Luna", entryDate: new DateTime(2012, 3, 1));
            var commetLuna1 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 1));
            var commetLuna2 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 2));
            var commetLuna3 = TestUtil.CreateNewComment(entryLuna, new DateTime(2012, 3, 3));

            TestUtil.UpdateIndex();

            var manager = new Mod.CommentManager();
            var comments = manager.GetEntryComments(entryLuna, 2);
            var ids = from comment in comments select comment.ID;

            Assert.That(ids, Is.EqualTo(new[] { commetLuna1.ID, commetLuna2.ID }));
        }