示例#1
0
        public void GetCommentForumsBySitenameXML_WithEditorsPickFilter()
        {
            var request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();

            //create the forum
            CommentForum commentForum = CommentForumCreateHelper();

            //Create 2 Comments in the same forum.
            var comments = new CommentsTests_V1();
            CommentInfo commentInfo = comments.CreateCommentHelper(commentForum.Id);
            CommentInfo commentInfo2 = comments.CreateCommentHelper(commentForum.Id);

            //Create Editors Pick on first comment
            var editorsPicks = new EditorsPicks_V1();
            editorsPicks.CreateEditorsPickHelper(_sitename, commentInfo.ID);


            // Filter forum on editors picks filter
            string url =
                String.Format(
                    "http://" + _server +
                    "/dna/api/comments/CommentsService.svc/V1/site/h2g2/commentsforums/{0}/?filterBy=EditorPicks",
                    commentForum.Id);

            //Check that picked comment is in results.
            request.RequestPageWithFullURL(url, "", "text/xml");
            XmlDocument xml = request.GetLastResponseAsXML();

            //Check XML.
            var validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForumList);
            validator.Validate();

            var nsmgr = new XmlNamespaceManager(xml.NameTable);
            nsmgr.AddNamespace("api", "BBC.Dna.Api");

            // Check comment is included in picks.
            String xPath = String.Format("api:commentForum/api:commentsList/api:comments/api:comment[api:id='{0}']",
                                         commentInfo.ID);
            XmlNode pick = xml.SelectSingleNode(xPath, nsmgr);
            Assert.IsNotNull(pick);

            //Check Comment that has not been picked is not present.
            xPath = String.Format("api:commentForum/api:commentsList/api:comments/api:comment[api:id='{0}']",
                                  commentInfo2.ID);
            pick = xml.SelectSingleNode(xPath, nsmgr);
            Assert.IsNull(pick);
        }
示例#2
0
        public void GetReviewForumWithEditorsPickFilter()
        {
            //Create 2 Comments
            CommentsTests_V1 comments = new CommentsTests_V1();
            CommentForumTests_V1 commentForums = new CommentForumTests_V1();
            CommentInfo commentInfo = comments.CreateCommentHelper(commentForums.CommentForumCreateHelper().Id);
            CommentInfo commentInfo2 = comments.CreateCommentHelper(commentForums.CommentForumCreateHelper().Id);

            //Create Editors Pick on 1st comment only.
            EditorsPicks_V1 editorsPicks = new EditorsPicks_V1();
            editorsPicks.CreateEditorsPickHelper(_sitename, commentInfo.ID);


            //Request Comments Filtered by Editors Picks.
            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();

            // Setup the request url
            string url = commentInfo.ForumUri + "?filterBy=EditorsPick";
            
            //Check that picked comment is in results.
            request.RequestPageWithFullURL(url, "", "text/xml");
            XmlDocument xml = request.GetLastResponseAsXML();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable);
            nsmgr.AddNamespace("api", "BBC.Dna.Api");

            String xPath = String.Format("api:ratingForum/api:commentsList/api:comments/api:comment[api:id='{0}']", commentInfo.ID);
            XmlNode pick = xml.SelectSingleNode(xPath, nsmgr);
            Assert.IsNotNull(pick);

            //Check Comment that has not been picked is not present.
            xPath = String.Format("api:ratingForum/api:commentsList/api:comments/api:comment[api:id='{0}']", commentInfo2.ID);
            pick = xml.SelectSingleNode(xPath, nsmgr);
            Assert.IsNull(pick);

        }
示例#3
0
        public void ReviewsWithEditorsPickFilter()
        {
            RatingForum ratingForum = RatingForumCreate("editorpickstests", Guid.NewGuid().ToString());

            //Create Review.
            RatingInfo reviewInfo = CreateRatingHelper(ratingForum.Id, false);
            RatingInfo reviewInfo2 = CreateRatingHelper(ratingForum.Id, true);

            //Create Editors Pick
            EditorsPicks_V1 editorsPicks = new EditorsPicks_V1();
            editorsPicks.CreateEditorsPickHelper(_sitename, reviewInfo.ID);


            //Request Reviews Filtered by Editors Picks.
            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();

            // Setup the request url
            string url = String.Format("http://" + _server + "/dna/api/comments/ReviewService.svc/V1/site/{0}/reviewforum/{1}/?filterBy=EditorPicks", _sitename, ratingForum.Id);
            
            
            
            //Check that picked comment is in results.
            request.RequestPageWithFullURL(url, "", "text/xml");
            XmlDocument xml = request.GetLastResponseAsXML();

            BBC.Dna.Api.RatingForum returnedForum = (BBC.Dna.Api.RatingForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.RatingForum));
            Assert.IsTrue(returnedForum.Id == ratingForum.Id);
            Assert.IsTrue(returnedForum.ratingsList.TotalCount == 1);
            Assert.IsTrue(returnedForum.ratingsList.ratings[0].ID == reviewInfo.ID);
        }