Exemple #1
0
        public void ApproveCommentRemovesDeletedAndConfirmedSpamBits()
        {
            Entry        entry      = SetupBlogForCommentsAndCreateEntry();
            var          repository = new DatabaseObjectProvider();
            FeedbackItem comment    = CreateAndUpdateFeedbackWithExactStatus(entry, FeedbackType.Comment,
                                                                             FeedbackStatusFlag.ConfirmedSpam |
                                                                             FeedbackStatusFlag.Deleted);

            Assert.IsFalse(comment.Approved, "should not be approved");
            Assert.IsTrue(comment.Deleted, "should be deleted");
            Assert.IsTrue(comment.ConfirmedSpam, "should be confirmed spam");

            repository.Approve(comment, null);
            comment = repository.Get(comment.Id);
            Assert.IsTrue(comment.Approved, "Should be approved now.");
            Assert.IsFalse(comment.Deleted, "Should not be deleted.");
            Assert.IsFalse(comment.ConfirmedSpam, "Should not be confirmed spam.");
        }
        public void Create(int index)
        {
            DatabaseObjectProvider repository = new DatabaseObjectProvider();
            var feedbackItem = new FeedbackItem(FeedbackType.Comment)
            {
                Author    = "Phil",
                Title     = "Title" + index,
                Body      = "Who rocks the party that rocks the party? " + index,
                SourceUrl = new Uri("http://blah/")
            };

            var subtextContext = new Mock <ISubtextContext>();

            subtextContext.Setup(c => c.Cache).Returns(new TestCache());
            subtextContext.SetupBlog(BlogRequest.Current.Blog);
            subtextContext.SetupRepository(repository);
            subtextContext.Setup(c => c.HttpContext.Items).Returns(new Hashtable());
            var commentService = new CommentService(subtextContext.Object, null);

            commentService.Create(feedbackItem, true /*runFilters*/);
            repository.Approve(feedbackItem, null);
        }