public void CommentsListWithEditorsPickFilter() { Console.WriteLine("Before ViewUsersRating"); //Create Comment. RatingInfo commentInfo = CreateRatingHelper(); RatingInfo commentInfo2 = CreateRatingHelper(); //Create Editors Pick 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 = String.Format("http://" + _server + "/dna/api/comments/ReviewService.svc/V1/site/{0}/comments/?filterBy=EditorsPick", _sitename); //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:commentsList/api:comments/api:comment[api:id='{0}']/api:editorspick", 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}']/api:editorspick", commentInfo2.ID); pick = xml.SelectSingleNode(xPath, nsmgr); Assert.IsNull(pick); }
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); }
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); }