当前位置: 首页>>代码示例>>C#>>正文


C# DnaTestURLRequest.SetCurrentUserNotableUser方法代码示例

本文整理汇总了C#中Tests.DnaTestURLRequest.SetCurrentUserNotableUser方法的典型用法代码示例。如果您正苦于以下问题:C# DnaTestURLRequest.SetCurrentUserNotableUser方法的具体用法?C# DnaTestURLRequest.SetCurrentUserNotableUser怎么用?C# DnaTestURLRequest.SetCurrentUserNotableUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tests.DnaTestURLRequest的用法示例。


在下文中一共展示了DnaTestURLRequest.SetCurrentUserNotableUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCallingUserInfo_AsNotableUser_ReturnsNotablesItemInGroup

        public void GetCallingUserInfo_AsNotableUser_ReturnsNotablesItemInGroup()
        {
            Console.WriteLine("Before GetCallingUserInfo_AsModerator_ReturnsNotablesItemInGroup");

            DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
            request.SetCurrentUserNotableUser();
            request.RequestPageWithFullURL(callinguserfull_secure_url);

            BBC.Dna.Users.User user = (BBC.Dna.Users.User)StringUtils.DeserializeObject(request.GetLastResponseAsXML().OuterXml, typeof(BBC.Dna.Users.User));

            Assert.IsNotNull(user.UsersListOfGroups.Find(x => x.Name.ToLower() == "notables"));

            Console.WriteLine("After GetCallingUserInfo_AsModerator_ReturnsNotablesItemInGroup");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:14,代码来源:users.cs

示例2: makeTestItem

        public static int maxNumDiffUsers = 5; // different users as avaialble below

        public static string makeTestItem(string forumId, int index)
        {

            System.Random RandNum = new System.Random();
            int inputRating = RandNum.Next(1, 5);
            string ratingString = "";
            string ratingScore = "";
            string postData = testUtils_ratingsAPI.makeEntryPostXml_minimal(ref ratingString, ref ratingScore);
            string url = makeCreatePostUrl(forumId);

            DnaTestURLRequest theRequest = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
            theRequest.UseIdentitySignIn = true;

            switch (index)
            {
                case 0: theRequest.SetCurrentUserNormal(); break;
                case 1: theRequest.SetCurrentUserNotableUser(); break;
                case 2: theRequest.SetCurrentUserModerator(); break;
                case 3: theRequest.SetCurrentUserProfileTest(); break;
                case 4: theRequest.SetCurrentUserEditor(); break;
                default: Assert.Fail("Can only set up 5 different users. Other users are particularly special"); break;
            }

            try
            {
                theRequest.RequestPageWithFullURL(url, postData, "text/xml");
            }
            catch
            {
                string resp = theRequest.GetLastResponseAsString();
            }

            Assert.IsTrue(theRequest.CurrentWebResponse.StatusCode == HttpStatusCode.OK,
                "Error making test rating entity. Expecting " + HttpStatusCode.OK +
                " as response, got " + theRequest.CurrentWebResponse.StatusCode + "\n" +
                theRequest.CurrentWebResponse.StatusDescription
                );

            RatingInfo inf = (RatingInfo)StringUtils.DeserializeObject(theRequest.GetLastResponseAsString(), typeof(RatingInfo));

            return inf.ID.ToString();
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:44,代码来源:TestUtils_ratingsAPI.cs

示例3: CreateRating_AsNotable

        public void CreateRating_AsNotable()
        {
            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNotableUser();
            //create the forum
            RatingForum ratingForum = RatingForumCreate("tests", Guid.NewGuid().ToString());

            string text = "Functiontest Title" + Guid.NewGuid().ToString();
            string ratingForumXml = String.Format("<rating xmlns=\"BBC.Dna.Api\">" +
                "<text>{0}</text><rating>{1}</rating>" +
                "</rating>", text, 5);

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/ReviewService.svc/V1/site/{0}/reviewforum/{1}/", _sitename, ratingForum.Id);
            // now get the response
            request.RequestPageWithFullURL(url, ratingForumXml, "text/xml");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaRatingForum);
            validator.Validate();

            RatingInfo returnedRating = (RatingInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(RatingInfo));
            Assert.IsTrue(returnedRating.text == text);
            Assert.IsNotNull(returnedRating.User);
            Assert.IsTrue(returnedRating.User.UserId == request.CurrentUserID);
            Assert.AreEqual(true, returnedRating.User.Notable);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:27,代码来源:ratings_v1.cs

示例4: CreateRatingForumWithRating

        public void CreateRatingForumWithRating()
        {
            Console.WriteLine("Before CreateRating");

            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();
            string text = Guid.NewGuid().ToString();
            string uid = Guid.NewGuid().ToString();
            string template = "<ratingForum  xmlns=\"BBC.Dna.Api\"> " +
            "<id>{0}</id> " +
            "<title>{1}</title> " +
            "<parentUri>{2}</parentUri> " +
            "<ratingsList> " +
            "<ratings> " +
            "<rating> " +
            "<text>{3}</text> " +
            "<rating>{4}</rating> " +
            "</rating> " +
            "</ratings> " +
            "</ratingsList> " +
            "</ratingForum> ";

            string ratingXML = string.Format(template,
                uid, "title", "http://www.bbc.co.uk/dna/h2g2/",
                text, 5);

            

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/ReviewService.svc/V1/site/{0}/reviewforum/{1}/", _sitename, uid);
            // now get the response
            request.RequestPageWithFullURL(url, ratingXML, "text/xml", "PUT");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaRatingForum);
            validator.Validate();

            //get returned rating
            RatingInfo returnedRating = (RatingInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(RatingInfo));
            Assert.IsTrue(returnedRating.text == text);
            Assert.IsNotNull(returnedRating.User);
            Assert.IsTrue(returnedRating.User.UserId == request.CurrentUserID);

            //make another comment with the same uid
            text = Guid.NewGuid().ToString();
            ratingXML = string.Format(template,
                uid, "title", "http://www.bbc.co.uk/dna/h2g2/",
                text, 5);

            // now get the response
            request.SetCurrentUserNotableUser();//change user
            request.RequestPageWithFullURL(url, ratingXML, "text/xml", "PUT");
            // Check to make sure that the page returned with the correct information
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaRatingForum);
            validator.Validate();
            returnedRating = (RatingInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(RatingInfo));
            Assert.IsTrue(returnedRating.text == text);
            Assert.IsNotNull(returnedRating.User);
            Assert.IsTrue(returnedRating.User.UserId == request.CurrentUserID);



            Console.WriteLine("After CreateRating");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:65,代码来源:ratings_v1.cs

示例5: CreateAs_NotableUser

        public void CreateAs_NotableUser()
        {
            XmlDocument xml;
            DnaXmlValidator myValidator;
            DnaTestURLRequest myRequest = new DnaTestURLRequest(testUtils_ratingsAPI.sitename);

            string forumId = testUtils_ratingsAPI.makeTestForum();
            string ratingId = testUtils_ratingsAPI.makeTestItem(forumId);

            string url = makeCreatePickUrl(ratingId);
            string postData = testUtils_ratingsAPI.makeTimeStamp(); // needs some sort of post data otherwise it uses GET

            myRequest.SetCurrentUserNotableUser();

            try
            {
                myRequest.RequestPageWithFullURL(url, postData, "text/xml");
            }
            catch { }

            Assert.IsTrue(myRequest.CurrentWebResponse.StatusCode == HttpStatusCode.Unauthorized,
                "Should have been unauthorised. Got: " + myRequest.CurrentWebResponse.StatusCode + "\n" + myRequest.CurrentWebResponse.StatusDescription
                );

            xml = myRequest.GetLastResponseAsXML();
            myValidator = new DnaXmlValidator(xml.InnerXml, testUtils_ratingsAPI._schemaError);
            myValidator.Validate();
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:28,代码来源:editorsPicksTests_v1.cs

示例6: CreateRatingHelper

        /// <summary>
        /// Helper function to create rating for a given RatingForumID
        /// </summary>
        /// <param name="ratingForumID"></param>
        /// <returns></returns>
        public RatingInfo CreateRatingHelper(string ratingForumID, bool asNotable)
        {

            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            if (asNotable)
            {
                request.SetCurrentUserNotableUser();
            }
            else
            {
                request.SetCurrentUserNormal();
            }

            string text = "Functiontest Title" + Guid.NewGuid().ToString();
            string ratingForumXml = String.Format("<rating xmlns=\"BBC.Dna.Api\">" +
                "<text>{0}</text><rating>{1}</rating>" +
                "</rating>", text, 5);

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/ReviewService.svc/V1/site/{0}/reviewforum/{1}/", _sitename, ratingForumID);
            // now get the response
            request.RequestPageWithFullURL(url, ratingForumXml, "text/xml");
            // Check to make sure that the page returned with the correct information

            return (RatingInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(RatingInfo));

        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:32,代码来源:ratings_v1.cs

示例7: CreateComment_AsNotable_WithClosedForum

        public void CreateComment_AsNotable_WithClosedForum()
        {
            var request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNotableUser();
            //create the forum
            CommentForum commentForum = CommentForumCreate("tests", Guid.NewGuid().ToString());

            using (FullInputContext _context = new FullInputContext(""))
            {
                using (IDnaDataReader dataReader = _context.CreateDnaDataReader("updatecommentforumstatus"))
                {
                    dataReader.AddParameter("uid", commentForum.Id);
                    dataReader.AddParameter("canwrite", 0);
                    dataReader.Execute();
                }
            }

            string text = "Functiontest Title" + Guid.NewGuid().ToString();
            string commentForumXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
                "<text>{0}</text>" +
                "</comment>", text);

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/", _sitename, commentForum.Id);
            // now get the response
            request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
            validator.Validate();

            CommentInfo returnedComment = (CommentInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentInfo));
            Assert.IsTrue(returnedComment.text == text);
            Assert.IsNotNull(returnedComment.User);
            Assert.IsTrue(returnedComment.User.UserId == request.CurrentUserID);
            Assert.AreEqual(true, returnedComment.User.Notable);

            DateTime created = DateTime.Parse(returnedComment.Created.At);
            DateTime createdTest = BBC.Dna.Utils.TimeZoneInfo.GetTimeZoneInfo().ConvertUtcToTimeZone(DateTime.Now.AddMinutes(5));
            Assert.IsTrue(created < createdTest);//should be less than 5mins
            Assert.IsTrue(!String.IsNullOrEmpty(returnedComment.Created.Ago));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:42,代码来源:comments_v1.cs

示例8: CreateCommentForumWithComment

        public void CreateCommentForumWithComment()
        {
            Console.WriteLine("Before Createcomment");

            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();
            string text = Guid.NewGuid().ToString();
            string uid = Guid.NewGuid().ToString();
            string template = "<commentForum  xmlns=\"BBC.Dna.Api\"> " +
            "<id>{0}</id> " +
            "<title>{1}</title> " +
            "<parentUri>{2}</parentUri> " +
            "<commentsList> " +
            "<comments> " +
            "<comment> " +
            "<text>{3}</text> " +
            "</comment> " +
            "</comments> " +
            "</commentsList> " +
            "</commentForum> ";

            string commentXML = string.Format(template,
                uid, "title", "http://www.bbc.co.uk/dna/h2g2/",
                text);

            // used to check that a forum is actually created
            int finalForumcount = 0;
            int forumCount = testUtils_CommentsAPI.countForums(_sitename);

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/", _sitename, uid);
            // now get the response
            request.RequestPageWithFullURL(url, commentXML, "text/xml", "PUT");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaComment);
            validator.Validate();

            //get returned comment
            CommentInfo returnedcomment = (CommentInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentInfo));
            Assert.IsTrue(returnedcomment.text == text);
            Assert.IsNotNull(returnedcomment.User);
            Assert.IsTrue(returnedcomment.User.UserId == request.CurrentUserID);

            //make a second comment with the same uid, verb and post-data structure
            text = Guid.NewGuid().ToString();
            commentXML = string.Format(template,
                uid, "title", "http://www.bbc.co.uk/dna/h2g2/",
                text, 5);

            // now get the response
            request.SetCurrentUserNotableUser();//change user
            request.RequestPageWithFullURL(url, commentXML, "text/xml", "PUT");

            // Check to make sure that the page returned with the correct information
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaComment);
            validator.Validate();
            returnedcomment = (CommentInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentInfo));
            Assert.IsTrue(returnedcomment.text == text);
            Assert.IsNotNull(returnedcomment.User);
            Assert.IsTrue(returnedcomment.User.UserId == request.CurrentUserID);

            // count the fora for this site
            finalForumcount = testUtils_CommentsAPI.countForums(_sitename);
            // there should be 1 more
            Assert.AreEqual((forumCount + 1), finalForumcount);

            // Check that the new fourm actually contains the number of comments that we expect.
            request.RequestPageWithFullURL(url, "", "text/xml", "GET");

            CommentForum theForum = (CommentForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentForum));
            Assert.AreEqual(2, theForum.commentSummary.Total, "Made the wrong number of comments");

            Console.WriteLine("After Createcomment");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:76,代码来源:comments_v1.cs

示例9: CreateCommentsWithDifferentRatingsAndValidate

        private void CreateCommentsWithDifferentRatingsAndValidate(int apiVersion)
        {
            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();
            CommentForum commentForum = new CommentForum();
            CommentInfo commentInfo = new CommentInfo();
            CommentInfo commentInfo2 = new CommentInfo();
            CreateTestForumAndComment(ref commentForum, ref commentInfo);
            CreateTestForumAndComment(ref commentForum, ref commentInfo2);

            string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V{3}/site/{0}/commentsforums/{1}/comment/{2}/rate/up", _sitename, commentForum.Id, commentInfo.ID, apiVersion);
            // now get the response
            request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            //Assert.AreEqual("1", xml.DocumentElement.InnerText);
            if (apiVersion == 1)
            {
                Assert.AreEqual("1", xml.DocumentElement.InnerText);
            }
            else if (apiVersion == 2)
            {
                var neroRatingInfo = (NeroRatingInfo)StringUtils.DeserializeObject(xml.InnerXml, typeof(NeroRatingInfo));
                Assert.AreEqual(1, neroRatingInfo.neroValue);
                Assert.AreEqual(1, neroRatingInfo.positiveNeroValue);
                Assert.AreEqual(0, neroRatingInfo.negativeNeroValue);
            }
            else
            {
                Assert.Fail("We don't support any other version than 1 or 2");
            }

            request.SetCurrentUserModerator();
            request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
            xml = request.GetLastResponseAsXML();
            //Assert.AreEqual("2", xml.DocumentElement.InnerText);
            if (apiVersion == 1)
            {
                Assert.AreEqual("2", xml.DocumentElement.InnerText);
            }
            else if (apiVersion == 2)
            {
                var neroRatingInfo = (NeroRatingInfo)StringUtils.DeserializeObject(xml.InnerXml, typeof(NeroRatingInfo));
                Assert.AreEqual(2, neroRatingInfo.neroValue);
                Assert.AreEqual(2, neroRatingInfo.positiveNeroValue);
                Assert.AreEqual(0, neroRatingInfo.negativeNeroValue);
            }
            else
            {
                Assert.Fail("We don't support any other version than 1 or 2");
            }

            request.SetCurrentUserNotableUser();
            url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V{3}/site/{0}/commentsforums/{1}/comment/{2}/rate/down", _sitename, commentForum.Id, commentInfo2.ID, apiVersion);
            request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
            xml = request.GetLastResponseAsXML();
            //Assert.AreEqual("-1", xml.DocumentElement.InnerText);
            if (apiVersion == 1)
            {
                Assert.AreEqual("-1", xml.DocumentElement.InnerText);
            }
            else if (apiVersion == 2)
            {
                var neroRatingInfo = (NeroRatingInfo)StringUtils.DeserializeObject(xml.InnerXml, typeof(NeroRatingInfo));
                Assert.AreEqual(-1, neroRatingInfo.neroValue);
                Assert.AreEqual(0, neroRatingInfo.positiveNeroValue);
                Assert.AreEqual(-1, neroRatingInfo.negativeNeroValue);
            }
            else
            {
                Assert.Fail("We don't support any other version than 1 or 2");
            }

            //test as ascending
            url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?sortBy={2}&sortDirection={3}", _sitename, commentForum.Id, SortBy.RatingValue, SortDirection.Ascending);
            // now get the response
            request.RequestPageWithFullURL(url, null, "text/xml");
            xml = request.GetLastResponseAsXML();
            var validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
            validator.Validate();

            var returnedForum = (CommentForum)StringUtils.DeserializeObject(xml.InnerXml, typeof(CommentForum));
            Assert.AreEqual(commentInfo2.ID, returnedForum.commentList.comments[0].ID);
            Assert.AreEqual(commentInfo.ID, returnedForum.commentList.comments[1].ID);

            //test as ascending
            url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?sortBy={2}&sortDirection={3}", _sitename, commentForum.Id, SortBy.RatingValue, SortDirection.Descending);
            // now get the response
            request.RequestPageWithFullURL(url, null, "text/xml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
            validator.Validate();

            returnedForum = (CommentForum)StringUtils.DeserializeObject(xml.InnerXml, typeof(CommentForum));
            Assert.AreEqual(commentInfo.ID, returnedForum.commentList.comments[0].ID);
            Assert.AreEqual(commentInfo2.ID, returnedForum.commentList.comments[1].ID);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:97,代码来源:CommentsNeroRatings_v1.cs

示例10: CreateComment_AsNotable

        public void CreateComment_AsNotable()
        {
            var request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNotableUser();
            //create the forum
            CommentForum commentForum = CommentForumCreate("tests", Guid.NewGuid().ToString());

            string text = "Functiontest Title" + Guid.NewGuid().ToString();
            string commentForumXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
                "<text>{0}</text>" +
                "</comment>", text);

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/", _sitename, commentForum.Id);
            // now get the response
            request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
            validator.Validate();

            //check the TextAsHtml element
            //string textAsHtml = xml.DocumentElement.ChildNodes[2].InnerXml;
            //Assert.IsTrue(textAsHtml == "<div class=\"dna-comment text\" xmlns=\"\">" + text + "</div>");

            CommentInfo returnedComment = (CommentInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentInfo));
            Assert.IsTrue(returnedComment.text == text);
            Assert.IsNotNull(returnedComment.User);
            Assert.IsTrue(returnedComment.User.UserId == request.CurrentUserID);
            Assert.AreEqual(true, returnedComment.User.Notable);

            DateTime created = DateTime.Parse(returnedComment.Created.At);
            DateTime createdTest = BBC.Dna.Utils.TimeZoneInfo.GetTimeZoneInfo().ConvertUtcToTimeZone(DateTime.Now.AddMinutes(5));
            Assert.IsTrue(created < createdTest);//should be less than 5mins
            Assert.IsTrue(!String.IsNullOrEmpty(returnedComment.Created.Ago));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:36,代码来源:comments_v1.cs

示例11: CreateAs_NotableUser

        public void CreateAs_NotableUser()
        {
            XmlDocument xml;
            DnaXmlValidator myValidator;
            DnaTestURLRequest myRequest = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);

            string forumId = testUtils_CommentsAPI.makeTestCommentForum();
            string commentID = testUtils_CommentsAPI.makeTestComment(forumId);

            string url = String.Format(
                "http://{0}/dna/api/comments/CommentsService.svc/V1/site/{1}/comments/{2}/editorpicks/",
                testUtils_CommentsAPI.server, testUtils_CommentsAPI.sitename, commentID
                );
            string postData = testUtils_CommentsAPI.makeTimeStamp(); // needs some sort of post data otherwise it uses GET

            myRequest.SetCurrentUserNotableUser();

            try
            {
                myRequest.RequestPageWithFullURL(url, postData, "text/xml");
            }
            catch { }

            Assert.IsTrue(myRequest.CurrentWebResponse.StatusCode == HttpStatusCode.Unauthorized,
                "Should have been unauthorised. Got: " + myRequest.CurrentWebResponse.StatusCode + "\n" + myRequest.CurrentWebResponse.StatusDescription
                );

            xml = myRequest.GetLastResponseAsXML();
            myValidator = new DnaXmlValidator(xml.InnerXml, testUtils_CommentsAPI._schemaError);
            myValidator.Validate();
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:31,代码来源:editorsPicksTests_v1.cs

示例12: TestCreateNewPreModCommentForumAndUnicodeComment

        public void TestCreateNewPreModCommentForumAndUnicodeComment()
        {
            Console.WriteLine("Before CommentBoxTests - TestCreateNewPreModCommentForumAndUnicodeComment");

            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();

            // Setup the request url
            string uid = Guid.NewGuid().ToString();
            string encodedTitle = "\u041D\u0435 \u043F\u0430\u043D\u0438\u043A\u0443\u0439\u0442\u0435";
            string hosturl = "http://" + _server + "/dna/haveyoursay/acs";

            string url = "acswithoutapi?dnauid=" + uid + "&dnainitialtitle=" + encodedTitle + "&dnahostpageurl=" + hosturl + "&dnaforumduration=0&dnainitialmodstatus=premod&skin=purexml";

            // now get the response
            request.RequestPage(url);

            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag does not exist!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@UID='" + uid + "']") != null, "Forums uid does not matched the one used to create!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@HOSTPAGEURL='" + hosturl + "']") != null, "Host url does not match the one used to create!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@CANWRITE='1']") != null, "The forums can write flag should be set 1");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@MODERATIONSTATUS='3']") != null, "The forums moderation status should be 3 (premod)");

            // Now check to make sure that a normal users post gets premoderated
            string comment = "\u03CC\u03C7\u03B9 \u03C0\u03B1\u03BD\u03B9\u03BA\u03CC\u03C2 FromNormalUser" + uid;
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=" + comment + "&dnahostpageurl=" + hosturl + "&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag does not exist!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "1", "The forum should have 1 post!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST") != null, "Failed to create new comment");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST[@HIDDEN='3']") != null, "Failed to create new comment with hidden status 3");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST[SUBJECT='Hidden']") != null, "Failed to create new comment with hidden subject");

            // Now check to make sure that a notable can post a comment without being moderated
            request.SetCurrentUserNotableUser();
            string notableComment = "\u03CC\u03C7\u03B9 \u03C0\u03B1\u03BD\u03B9\u03BA\u03CC\u03C2 FromNotable" + uid;
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=" + notableComment + "&dnahostpageurl=" + hosturl + "&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag doers not exist!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "2", "The forum should have 2 post!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST[TEXT='" + notableComment + "']") != null, "Posted comment did not appear for notable!!!");

            // Now check to make sure that a editor can post a comment without being moderated
            request.SetCurrentUserEditor();
            string editorComment = "\u03CC\u03C7\u03B9 \u03C0\u03B1\u03BD\u03B9\u03BA\u03CC\u03C2 FromEditor" + uid;
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=" + editorComment + "&dnahostpageurl=" + hosturl + "&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag doers not exist!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "3", "The forum should have 3 post!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST[TEXT='" + editorComment + "']") != null, "Posted comment did not appear for editor!!!");

            Console.WriteLine("After CommentBoxTests - TestCreateNewPreModCommentForumAndUnicodeComment");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:63,代码来源:CommentBoxTests.cs

示例13: TestCreateNewCommentForumAndCommentOnEmergencyClosedSite

        public void TestCreateNewCommentForumAndCommentOnEmergencyClosedSite()
        {
            Console.WriteLine("Before CommentBoxTests - TestCreateNewCommentForumAndCommentOnEmergencyClosedSite");
            _doOpenSite = true;

            // Start by emergency closing the site.
            Assert.IsTrue(SetSiteEmergencyClosed(true), "Failed to close the site in a timely fashion!!!");

            DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
            
            //request.SetCurrentUserEditor();
            //request.UseEditorAuthentication = true;
            //request.RequestPage("messageboardschedule?action=closesite&confirm=1&skin=purexml");
            //XmlDocument xml = request.GetLastResponseAsXML();
            //Assert.AreEqual(xml.SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "1", "The haveyoursay site was not closed correctly! Please check your database!");

            //// Now wait untill the .net has been signaled by ripley that we need to recache site data. Emergency closed is in the data!!!
            //// Make sure we've got a drop clause after 15 seconds!!!
            //DateTime time = DateTime.Now.AddSeconds(30);
            //bool siteIsClosed = false;
            //while (!siteIsClosed && time > DateTime.Now)
            //{
            //    request.RequestPage("acswithoutapi?skin=purexml");
            //    if (request.GetLastResponseAsXML().SelectSingleNode("//SITE/SITECLOSED") != null)
            //    {
            //        siteIsClosed = request.GetLastResponseAsXML().SelectSingleNode("//SITE/SITECLOSED").InnerXml.CompareTo("1") == 0;
            //    }
            //}

            // Setup the request url
            string uid = Guid.NewGuid().ToString();
            string title = "TestingCommentBox";
            string hosturl = "http://" + _server + "/dna/haveyoursay/acs";

            string url = "acswithoutapi?dnauid=" + uid + "&dnainitialtitle=" + title + "&dnahostpageurl=" + hosturl + "&dnaforumduration=0&skin=purexml";

            // now get the response
            request.SetCurrentUserNormal();
            request.UseEditorAuthentication = false;
            request.RequestPage(url);

            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag doers not exist!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/ENDDATE") == null, "End date missing when specified!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@UID='" + uid + "']") != null, "Forums uid does not matched the one used to create!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@HOSTPAGEURL='" + hosturl + "']") != null, "Host url does not match the one used to create!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@CANWRITE='0']") != null, "The forums can write flag should be set 0");
            Assert.IsTrue(xml.SelectSingleNode("//SITE[SITECLOSED='1']") != null, "haveyoursay site is not closed when we set the test to close it.");

            // Now check to make sure that a normal users post gets premoderated
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblahFromNormalUser&dnahostpageurl=" + hosturl + "&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag doers not exist!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "0", "The forum should have 1 post!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST") == null, "Normal user should not be able to post to a closed site!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@CANWRITE='0']") != null, "The forums can write flag should be set 0");
            Assert.IsTrue(xml.SelectSingleNode("//SITE[SITECLOSED='1']") != null, "haveyoursay site is not closed when we set the test to close it.");

            // Now check to make sure that a notable can post a comment without being moderated
            request.SetCurrentUserNotableUser();
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblahFromNotableUser&dnahostpageurl=" + hosturl + "&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "0", "The forum should have 1 post!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST") == null, "Notable user should not be able to post to a closed site!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@CANWRITE='0']") != null, "The forums can write flag should be set 0");
            Assert.IsTrue(xml.SelectSingleNode("//SITE[SITECLOSED='1']") != null, "haveyoursay site is not closed when we set the test to close it.");

            // Now check to make sure that a editor can post a comment without being moderated
            request.SetCurrentUserEditor();
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblahFromEditor&dnahostpageurl=" + hosturl + "&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag doers not exist!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "1", "The forum should have 1 post!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST[TEXT='blahblahblahFromEditor']") != null, "Posted comment did not appear for editor!!!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@CANWRITE='0']") != null, "The forums can write flag should be set 0 even for editors as the forum is cached as if a normal user is viewing the page when closed");
            Assert.IsTrue(xml.SelectSingleNode("//SITE[SITECLOSED='1']") != null, "haveyoursay site is not closed when we set the test to close it.");


            SetSiteEmergencyClosed(false);
            Console.WriteLine("After CommentBoxTests - TestCreateNewCommentForumAndCommentOnEmergencyClosedSite");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:90,代码来源:CommentBoxTests.cs

示例14: RateUpComment_SortByRatingValue_ReturnsCorrectOrder

        public void RateUpComment_SortByRatingValue_ReturnsCorrectOrder()
        {
            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();
            CommentForum commentForum = new CommentForum();
            CommentInfo commentInfo = new CommentInfo();
            CommentInfo commentInfo2 = new CommentInfo();
            CreateTestForumAndComment(ref commentForum, ref commentInfo);
            CreateTestForumAndComment(ref commentForum, ref commentInfo2);

            string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/comment/{2}/rate/up", _sitename, commentForum.Id, commentInfo.ID);
            // now get the response
            request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            Assert.AreEqual("1", xml.DocumentElement.InnerText);


            request.SetCurrentUserModerator();
            request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
            xml = request.GetLastResponseAsXML();
            Assert.AreEqual("2", xml.DocumentElement.InnerText);

            request.SetCurrentUserNotableUser();
            url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/comment/{2}/rate/down", _sitename, commentForum.Id, commentInfo2.ID);
            request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
            xml = request.GetLastResponseAsXML();
            Assert.AreEqual("-1", xml.DocumentElement.InnerText);

            //test as ascending
            url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?sortBy={2}&sortDirection={3}", _sitename, commentForum.Id, SortBy.RatingValue, SortDirection.Ascending);
            // now get the response
            request.RequestPageWithFullURL(url, null, "text/xml");
            xml = request.GetLastResponseAsXML();
            var validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
            validator.Validate();

            var returnedForum = (CommentForum)StringUtils.DeserializeObject(xml.InnerXml, typeof(CommentForum));
            Assert.AreEqual(commentInfo2.ID, returnedForum.commentList.comments[0].ID);
            Assert.AreEqual(commentInfo.ID, returnedForum.commentList.comments[1].ID);

            //test as ascending
            url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?sortBy={2}&sortDirection={3}", _sitename, commentForum.Id, SortBy.RatingValue, SortDirection.Descending);
            // now get the response
            request.RequestPageWithFullURL(url, null, "text/xml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
            validator.Validate();

            returnedForum = (CommentForum)StringUtils.DeserializeObject(xml.InnerXml, typeof(CommentForum));
            Assert.AreEqual(commentInfo.ID, returnedForum.commentList.comments[0].ID);
            Assert.AreEqual(commentInfo2.ID, returnedForum.commentList.comments[1].ID);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:53,代码来源:CommentsNeroRatings_v1.cs

示例15: PostToForumWithException

        private DnaTestURLRequest PostToForumWithException(DnaTestURLRequest request, string post, DnaTestURLRequest.usertype user)
        {
            var url = String.Format("PostToForum?skin=purexml&forumid=" + _forumId.ToString());

            if (user == DnaTestURLRequest.usertype.EDITOR)
            {
                request.SetCurrentUserEditor();
            }
            else if (user == DnaTestURLRequest.usertype.SUPERUSER)
            {
                request.SetCurrentUserSuperUser();
            }
            else if (user == DnaTestURLRequest.usertype.NOTABLE)
            {
                request.SetCurrentUserNotableUser();
            }
            else if (user == DnaTestURLRequest.usertype.NORMALUSER)
            {
                request.SetCurrentUserNormal();
            }

            var postParams = new Queue<KeyValuePair<string, string>>();
            postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("threadid", _threadId.ToString()));
            postParams.Enqueue(new KeyValuePair<string, string>("inreplyto", _inReplyTo.ToString()));
            postParams.Enqueue(new KeyValuePair<string, string>("dnapoststyle", "1"));
            postParams.Enqueue(new KeyValuePair<string, string>("forum", _forumId.ToString()));
            postParams.Enqueue(new KeyValuePair<string, string>("subject", "test post"));
            postParams.Enqueue(new KeyValuePair<string, string>("body", post));
            postParams.Enqueue(new KeyValuePair<string, string>("post", "Post message"));

            try
            {
                request.RequestPage(url, postParams);
            }
            catch { }
            return request;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:38,代码来源:PostToForumTests.cs


注:本文中的Tests.DnaTestURLRequest.SetCurrentUserNotableUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。