Esempio n. 1
0
        public void CreateTrackbackSetsFeedbackTypeCorrectly()
        {
            string hostname = UnitTestHelper.GenerateUniqueString();
            var repository = new DatabaseObjectProvider();
            repository.CreateBlog("", "username", "password", hostname, string.Empty);
            UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty, string.Empty);
            Blog blog = repository.GetBlog(hostname, string.Empty);
            BlogRequest.Current.Blog = blog;

            Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("phil", "title", "body");
            int parentId = UnitTestHelper.Create(entry);

            var trackback = new Trackback(parentId, "title", new Uri("http://url"), "phil", "body");
            var subtextContext = new Mock<ISubtextContext>();
            subtextContext.Setup(c => c.Blog).Returns(Config.CurrentBlog);
            //TODO: FIX!!!
            subtextContext.Setup(c => c.Repository).Returns(repository);
            subtextContext.Setup(c => c.Cache).Returns(new TestCache());
            subtextContext.Setup(c => c.HttpContext.Items).Returns(new Hashtable());
            var commentService = new CommentService(subtextContext.Object, null);
            int id = commentService.Create(trackback, true/*runFilters*/);

            FeedbackItem loadedTrackback = repository.Get(id);
            Assert.IsNotNull(loadedTrackback, "Was not able to load trackback from storage.");
            Assert.AreEqual(FeedbackType.PingTrack, loadedTrackback.FeedbackType, "Feedback should be a PingTrack");
        }
Esempio n. 2
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.");
        }
Esempio n. 3
0
        static FeedbackItem CreateAndUpdateFeedbackWithExactStatus(Entry entry, FeedbackType type,
                                                                   FeedbackStatusFlag status)
        {
            var repository = new DatabaseObjectProvider();
            var feedback = new FeedbackItem(type);
            feedback.Title = UnitTestHelper.GenerateUniqueString();
            feedback.Body = UnitTestHelper.GenerateUniqueString();
            feedback.EntryId = entry.Id;
            feedback.Author = "TestAuthor";

            var subtextContext = new Mock<ISubtextContext>();
            subtextContext.Setup(c => c.Cache).Returns(new TestCache());
            subtextContext.SetupBlog(Config.CurrentBlog);
            subtextContext.SetupRepository(repository);
            subtextContext.Setup(c => c.HttpContext.Items).Returns(new Hashtable());
            subtextContext.Setup(c => c.HttpContext).Returns(new HttpContextWrapper(HttpContext.Current));

            var service = new CommentService(subtextContext.Object, null);
            int id = service.Create(feedback, true/*runFilters*/);

            feedback = repository.Get(id);
            feedback.Status = status;
            repository.Update(feedback);

            return repository.Get(id);
        }
Esempio n. 4
0
        public void DeleteCommentSetsDeletedBit()
        {
            Entry entry = SetupBlogForCommentsAndCreateEntry();
            var repository = new DatabaseObjectProvider();
            FeedbackItem comment = CreateAndUpdateFeedbackWithExactStatus(entry, FeedbackType.Comment, FeedbackStatusFlag.Approved);
            Assert.IsTrue(comment.Approved, "should be approved");

            repository.Delete(comment);
            comment = repository.Get(comment.Id);
            Assert.IsFalse(comment.Approved, "Should not be approved now.");
            Assert.IsTrue(comment.Deleted, "Should be moved to deleted folder now.");
        }