GetFeedbackForEntry() 공개 메소드

Returns all the active entries for the specified post.
public GetFeedbackForEntry ( Entry parentEntry ) : IList
parentEntry Subtext.Framework.Components.Entry
리턴 IList
예제 #1
0
        public void TrackbackShowsUpInFeedbackList()
        {
            string hostname = UnitTestHelper.GenerateUniqueString();
            var repository = new DatabaseObjectProvider();
            repository.CreateBlog("", "username", "password", hostname, "blog");
            UnitTestHelper.SetHttpContextWithBlogRequest(hostname, "blog", string.Empty);
            Blog blog = repository.GetBlog(hostname, "blog");
            BlogRequest.Current.Blog = blog;

            Entry parentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("philsath aeuoa asoeuhtoensth",
                                                                                 "sntoehu title aoeuao eu",
                                                                                 "snaot hu aensaoehtu body");
            int parentId = UnitTestHelper.Create(parentEntry);

            ICollection<FeedbackItem> entries = repository.GetFeedbackForEntry(parentEntry);
            Assert.AreEqual(0, entries.Count, "Did not expect any feedback yet.");

            var trackback = new Trackback(parentId, "title", new Uri("http://url"), "phil", "body");
            Config.CurrentBlog.DuplicateCommentsEnabled = true;
            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());
            var commentService = new CommentService(subtextContext.Object, null);
            int trackbackId = commentService.Create(trackback, true/*runFilters*/);

            new DatabaseObjectProvider().Approve(trackback, null);

            entries = repository.GetFeedbackForEntry(parentEntry);
            Assert.AreEqual(1, entries.Count, "Expected a trackback.");
            Assert.AreEqual(trackbackId, entries.First().Id,
                            "The feedback was not the same one we expected. The IDs do not match.");
        }
예제 #2
0
        public void ProcessRequest_WithValidTrackback_CreatesTracbackRecordInDatabase()
        {
            //arrange
            var repository = new DatabaseObjectProvider();
            UnitTestHelper.SetupBlog();
            Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("phil", "this is the title", "body");
            entry.DateCreatedUtc =
                entry.DatePublishedUtc =
                entry.DateModifiedUtc = DateTime.ParseExact("2006/05/25", "yyyy/MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToUniversalTime();
            int id = UnitTestHelper.Create(entry);
            Blog blog = Config.CurrentBlog;
            blog.TrackbacksEnabled = true;
            var subtextContext = new Mock<ISubtextContext>();
            StringWriter writer = subtextContext.FakeSubtextContextRequest(blog, "/trackbackhandler", "/", string.Empty);
            subtextContext.Setup(c => c.Repository).Returns(repository);
            subtextContext.Object.RequestContext.RouteData.Values.Add("id", id.ToString());
            subtextContext.SetupBlog(blog);
            var handler = new TrackBackHandler(subtextContext.Object);
            handler.SourceVerification += (sender, e) => e.Verified = true;
            Mock<BlogUrlHelper> urlHelper = Mock.Get(subtextContext.Object.UrlHelper);
            urlHelper.Setup(u => u.EntryUrl(It.IsAny<Entry>())).Returns("/whatever/entry");
            urlHelper.Setup(u => u.TrackbacksUrl(It.IsAny<int>())).Returns("/whatever/trackback");
            Mock<HttpContextBase> httpContext = Mock.Get(subtextContext.Object.RequestContext.HttpContext);
            httpContext.Setup(c => c.Request.HttpMethod).Returns("POST");

            var form = new NameValueCollection();
            form["title"] = entry.Title;
            form["excert"] = entry.Body;
            form["url"] = "http://myblog.example.com/";
            form["blog_name"] = "Random Blog";

            httpContext.Setup(c => c.Request.Form).Returns(form);

            //act
            handler.ProcessRequest();

            //assert
            ICollection<FeedbackItem> trackbacks = repository.GetFeedbackForEntry(entry);
            Assert.AreEqual(1, trackbacks.Count, "We expect to see the one feedback we just created.");
            Assert.AreEqual("this is the title", trackbacks.First().Title);
        }