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


C# DnaTestURLRequest.RequestSecurePage方法代码示例

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


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

示例1: CallCommentForumList

 public static string CallCommentForumList(DnaTestURLRequest request, string additionalParams)
 {
     string requestURL = "admin/commentsforumlist?s_siteid=1" + additionalParams;
     request.SetCurrentUserEditor();
     request.AssertWebRequestFailure = false;
     request.RequestSecurePage(requestURL);
     return requestURL;
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:8,代码来源:CommentForumTestUtils.cs

示例2: CallCommentForumList

 public static string CallCommentForumList(DnaTestURLRequest request, string sitename, string contactFormID, string additionalParams)
 {
     string requestURL = "https://" + DnaTestURLRequest.CurrentServer + "/dna/" + sitename + "/commentsforumlist/?s_siteid=1" + additionalParams;
     request.SetCurrentUserEditor();
     request.AssertWebRequestFailure = false;
     request.RequestSecurePage(requestURL);
     return requestURL;
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:8,代码来源:ContactFormTestUtils.cs

示例3: SetSiteOptionForAnonymousPosting

 public static void SetSiteOptionForAnonymousPosting(DnaTestURLRequest request, bool allow)
 {
     request.SetCurrentUserSuperUser();
     string requestURL = "SiteOptions?siteid=1&so_1_CommentForum_AllowNotSignedInCommenting=1&sov_1_CommentForum_AllowNotSignedInCommenting=";
     requestURL += allow ? "1" : "0";
     requestURL += "&cmd=update&skin=purexml";
     request.RequestSecurePage(requestURL);
     Thread.Sleep(3000);
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:9,代码来源:CommentForumTestUtils.cs

示例4: TestModerateHomePageSecure

        public void TestModerateHomePageSecure()
        {
            Console.WriteLine("Before moderationhome Page Tests - TestModerateHomePageSecure");
            DnaTestURLRequest request = new DnaTestURLRequest("moderation");
            request.UseEditorAuthentication = true;
            request.SetCurrentUserEditor();  

            request.RequestSecurePage(@"moderationhome?skin=purexml");
            XmlDocument xml = request.GetLastResponseAsXML();

            Console.WriteLine("After moderationhome Page Tests - TestModerateHomePageSecure");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:12,代码来源:ModerateHomePageTests.cs

示例5: TestModerateHomePageSecure

        public void TestModerateHomePageSecure()
        {
            Console.WriteLine("Before ModerateHome Page Tests - TestModerateHomePageSecure");
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");

            Cookie cookie;
            string testUserName;
            SetupIdentityEditorUser(request, out cookie, out testUserName);

            request.RequestSecurePage(@"NModerate?skin=purexml");
            XmlDocument xml = request.GetLastResponseAsXML();

            TestUserCreator.DeleteIdentityUser(cookie, testUserName);
            request.Dispose();
            Console.WriteLine("After ModerateHome Page Tests - TestModerateHomePageSecure");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:16,代码来源:ModerateHomePageTests.cs

示例6: TestSetup

        public void TestSetup()
        {
            // Create the stored procedure reader for the setup
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.UseIdentitySignIn = true;
            request.SetCurrentUserNormal();

            // Setup the request url
            string uid = Guid.NewGuid().ToString();
            string title = "TestingCommentBox";
            string hosturl = "http://local.bbc.co.uk/dna/haveyoursay/acs";
            string url = "acs?dnauid=" + uid + "&dnainitialtitle=" + title + "&dnahostpageurl=" + hosturl + "&dnaforumduration=0&skin=purexml";

            // Request the page and then post a comment
            request.RequestPage(url);
            XmlDocument xml = request.GetLastResponseAsXML();
            request.RequestSecurePage("acs?dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblah&dnahostpageurl=" + hosturl + "&skin=purexml");
            XmlDocument xDoc = request.GetLastResponseAsXML();
            _entryID = Convert.ToInt32(xDoc.SelectSingleNode("//POST/@POSTID").InnerText);

            bool haveIpInfo = false;
            IInputContext context = DnaMockery.CreateDatabaseInputContext();
            using (IDnaDataReader reader = context.CreateDnaDataReader(""))
            {
                reader.ExecuteDEBUGONLY("SELECT TOP 1 EntryID FROM ThreadEntriesIpAddress WHERE entryid = " + _entryID.ToString() + " and ipaddress = '12.34.56.78' and bbcuid = '47BEB336-3409-00CF-CAD0-080020C4C7DD'");
                if (reader.Read() && reader.HasRows)
                {
                    haveIpInfo = true;
                }
            }

            // Check to see if we had the ip details added
            if (!haveIpInfo)
            {
                // No details. Insert them manualy
                using (IDnaDataReader reader = context.CreateDnaDataReader(""))
                {
                    reader.ExecuteDEBUGONLY("UPDATE ThreadEntriesIpAddress SET entryid = " + _entryID.ToString() + ", ipaddress = '12.34.56.78', bbcuid = '47BEB336-3409-00CF-CAD0-080020C4C7DD' WHERE EntryID = " + _entryID.ToString());
                    reader.Read();
                }
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:42,代码来源:MemberListTests.cs

示例7: TestCreateNewCommentForumAndComment

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

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

            // 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.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/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='1']") != null, "The forums can write flag should be set 1");

            // Now check to make sure we can post to the comment box
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblah&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 post a comment!!!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST[TEXT='blahblahblah']") != null, "Posted comment did not appear!!!");

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

示例8: TestBasicErrorsAndParsing

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

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

            // 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&dnainitialmodstatus=premod&skin=purexml";

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

            // Check for parsing errors in guideml posts
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblah2<From>NormalUser&dnahostpageurl=" + hosturl + "&dnapoststyle=1&skin=purexml");
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsNotNull(xml.SelectSingleNode("//ERROR[@TYPE='XmlParseError']"), "Failed to find the XMLError error");
            Assert.AreEqual("blahblahblah2%3CFrom%3ENormalUser", xml.SelectSingleNode("//ORIGINALPOSTTEXT").InnerText, "The original text should be 'blahblahblah2%C3From%3ENormalUser'");

            // Check for correct handling for profanities
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=blahblah1blah3NormalUser fuck&dnahostpageurl=" + hosturl + "&poststyle=1&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            Assert.IsNotNull(xml.SelectSingleNode("//ERROR[@TYPE='profanityblocked']"), "Failed to find the Profanity Blocked error");
            Assert.AreEqual("blahblah1blah3NormalUser%20fuck", xml.SelectSingleNode("//ORIGINALPOSTTEXT").InnerText, "The original text should be 'blahblah1blah3NormalUser%20fuck'");

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

示例9: TestModerateHomePageUnlockAll

        public void TestModerateHomePageUnlockAll()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            Cookie cookie;
            string testUserName;
            SetupIdentityEditorUser(request, out cookie, out testUserName);
/*
            modHomeParams.UnlockForums = InputContext.DoesParamExist("UnlockForums", _docDnaUnlockForums);
            modHomeParams.UnlockForumReferrals = InputContext.DoesParamExist("UnlockForumReferrals", _docDnaUnlockForumReferrals);
            modHomeParams.UnlockUserPosts = InputContext.DoesParamExist("UnlockUserPosts", _docDnaUnlockUserPosts);
            modHomeParams.UnlockSitePosts = InputContext.DoesParamExist("UnlockSitePosts", _docDnaUnlockSitePosts);
            modHomeParams.UnlockAllPosts = InputContext.DoesParamExist("UnlockAllPosts", _docDnaUnlockAllPosts);
            modHomeParams.UnlockArticles = InputContext.DoesParamExist("UnlockArticles", _docDnaUnlockArticles);
            modHomeParams.UnlockArticleReferrals = InputContext.DoesParamExist("UnlockArticleReferrals", _docDnaUnlockArticleReferrals);
            modHomeParams.UnlockGeneral = InputContext.DoesParamExist("UnlockGeneral", _docDnaUnlockGeneral);
            modHomeParams.UnlockGeneralReferrals = InputContext.DoesParamExist("UnlockGeneralReferrals", _docDnaUnlockGeneralReferrals);
            modHomeParams.UnlockNicknames = InputContext.DoesParamExist("UnlockNicknames", _docDnaUnlockNicknames);
            modHomeParams.UnlockAll = InputContext.DoesParamExist("UnlockAll", _docDnaUnlockAll);
*/
            request.RequestSecurePage(@"NModerate?UnlockForums=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockForumReferrals=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockUserPosts=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockSitePosts=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockAllPosts=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockArticles=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockArticleReferrals=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockGeneral=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockGeneralReferrals=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockNicknames=1&skin=purexml");
            request.RequestSecurePage(@"NModerate?UnlockAll=1&skin=purexml");

            XmlDocument xml = request.GetLastResponseAsXML();

            TestUserCreator.DeleteIdentityUser(cookie, testUserName);
            request.Dispose();
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:36,代码来源:ModerateHomePageTests.cs

示例10: Test5CheckThatCanWriteFlagGetSetAccordinglyInRespectToForumClosingDate

        public void Test5CheckThatCanWriteFlagGetSetAccordinglyInRespectToForumClosingDate()
        {
            // Create a new comment box with no closing date
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();

            // Setup the request url
            string forumClosingDate = DateTime.Today.AddDays(10).Year.ToString();
            if (DateTime.Today.AddDays(10).Month.ToString().Length == 1)
            {
                forumClosingDate += "0";
            }
            forumClosingDate += DateTime.Today.AddDays(10).Month.ToString();
            if (DateTime.Today.AddDays(10).Day.ToString().Length == 1)
            {
                forumClosingDate += "0";
            }
            forumClosingDate += DateTime.Today.AddDays(10).Day.ToString();

            string uid = Guid.NewGuid().ToString();
            string title = "Testing";
            string hosturl = "http://local.bbc.co.uk/dna/haveyoursay/acs";
            string url = "acs?dnauid=" + uid + "&dnainitialtitle=" + title + "&dnahostpageurl=" + hosturl + "&dnaforumclosedate=" + forumClosingDate + "&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.OuterXml, _schemaUri);
            validator.Validate();

            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag does not exist!");
            XmlNode date = xml.SelectSingleNode("/H2G2/COMMENTBOX/ENDDATE/DATE/LOCAL");
            Assert.IsTrue(date != null, "End date missing when specified!");
            Assert.AreEqual(DateTime.Today.AddDays(10 + 1).ToString("MM"), date.Attributes["MONTH"].Value);
            Assert.AreEqual(DateTime.Today.AddDays(10 + 1).ToString("dd"), date.Attributes["DAY"].Value);
            Assert.AreEqual(DateTime.Today.AddDays(10 + 1).ToString("yyyy"), date.Attributes["YEAR"].Value);

            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");

            // Now ste the closing date of the forum to something in the past.
            using (IDnaDataReader dataReader = _context.CreateDnaDataReader("updatecommentforumstatus"))
            {
                dataReader.AddParameter("uid", uid);
                dataReader.AddParameter("forumclosedate", DateTime.Today.AddDays(-20));
                dataReader.Execute();
            }

            // now get the response
            request.RequestPage("acs?dnauid=" + uid + "&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.OuterXml, _schemaUri);
            validator.Validate();

            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag does not exist!");
            date = xml.SelectSingleNode("/H2G2/COMMENTBOX/ENDDATE/DATE/LOCAL");
            Assert.IsTrue(date != null, "End date missing when specified!");
            Assert.AreEqual(DateTime.Today.AddDays(-20).ToString("MM"), date.Attributes["MONTH"].Value);
            Assert.AreEqual(DateTime.Today.AddDays(-20).ToString("dd"), date.Attributes["DAY"].Value);
            Assert.AreEqual(DateTime.Today.AddDays(-20).ToString("yyyy"), date.Attributes["YEAR"].Value);

            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("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "0", "The forum not have any posts!");

            // Now make sure the user can't post to a closed forum
            request.RequestSecurePage("acs?dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblah&dnahostpageurl=" + hosturl + "&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.OuterXml, _schemaUri);
            validator.Validate();

            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag does not exist!");
            date = xml.SelectSingleNode("/H2G2/COMMENTBOX/ENDDATE/DATE/LOCAL");
            Assert.IsTrue(date != null, "End date missing when specified!");
            Assert.AreEqual(DateTime.Today.AddDays(-20).ToString("MM"), date.Attributes["MONTH"].Value);
            Assert.AreEqual(DateTime.Today.AddDays(-20).ToString("dd"), date.Attributes["DAY"].Value);
            Assert.AreEqual(DateTime.Today.AddDays(-20).ToString("yyyy"), date.Attributes["YEAR"].Value);

            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("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "0", "The forum not have any posts!");

            // Now make sure Editors can post to a closed forum
            request.SetCurrentUserEditor();
            request.RequestSecurePage("acs?dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblah&dnahostpageurl=" + hosturl + "&skin=purexml");
            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.OuterXml, _schemaUri);
            validator.Validate();

            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag does not exist!");
            date = xml.SelectSingleNode("/H2G2/COMMENTBOX/ENDDATE/DATE/LOCAL");
            Assert.IsTrue(date != null, "End date missing when specified!");
            Assert.AreEqual(DateTime.Today.AddDays(-20).ToString("MM"), date.Attributes["MONTH"].Value);
            Assert.AreEqual(DateTime.Today.AddDays(-20).ToString("dd"), date.Attributes["DAY"].Value);
            Assert.AreEqual(DateTime.Today.AddDays(-20).ToString("yyyy"), date.Attributes["YEAR"].Value);
//.........这里部分代码省略.........
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:101,代码来源:CommentForumClosingDateTests.cs

示例11: TestCommentWithALinkWithCRLFInItPostStyle1

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

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

            // 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.RequestPage(url);

            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();

            string dodgyLink = @"<a <href=""" + "\r\n" + @""">Test Link</a>";
            // Now check to make sure we can post to the comment box
            request.RequestSecurePage("acswithoutapi?skin=purexml&dnapoststyle=1&dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblah" + dodgyLink + "&dnahostpageurl=" + hosturl);

            // Check to make sure that the page returned with the correct information
            xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
            //<ERROR TYPE="XmlParseError">
            //<ERRORMESSAGE>The comment contains invalid xml.</ERRORMESSAGE> 
            //</ERROR>

            Assert.IsTrue(xml.SelectSingleNode("/H2G2/ERROR[@TYPE='XmlParseError']") != null, "Error not created.");

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

示例12: TestCommentWithALinkWithCRLFInIt

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

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

            // 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.RequestPage(url);

            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();

            //string dodgyLink = @"<a href='#" + "\r\n" + @"'>Test Link</a>";
            string dodgyLink = @"<a href=""http:" + "%0D%0A" + @""">Test Link</a>";
            // Now check to make sure we can post to the comment box
            request.RequestSecurePage("acswithoutapi?skin=purexml&dnauid=" + uid + "&dnaaction=add&dnacomment=blahblahblah" + dodgyLink + "&dnahostpageurl=" + hosturl);

            // Check to make sure that the page returned with the correct information
            xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();

            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/TEXT").InnerText == "blahblahblah<a href=\"http:\">Test Link</a>", "Post was created with the comment cut off.");

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

示例13: TestCommentWithDodgyCharInIt

        public void TestCommentWithDodgyCharInIt()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();

            Console.WriteLine("Before CommentBoxTests - TestCommentWithDodgyCharInIt");

            // 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.RequestPage(url);

            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();

            // Now check to make sure we can post to the comment box
            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=Test<character&dnahostpageurl=" + hosturl + "&skin=purexml");

            // Check to make sure that the page returned with the correct information
            xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();

            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/TEXT").InnerText == "Test<character", "Post was created with the comment marked up.");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/TEXT").InnerXml == "Test&lt;character", "Post was created with the comment marked up.");

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

示例14: TestCreateCommentSiteError

        public void TestCreateCommentSiteError()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();

            // Setup the request url
            string uid = Guid.NewGuid().ToString();
            string title = "TestCreateCommentWithChangeSite";
            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.RequestPage(url);

            // Now change site
            request = new DnaTestURLRequest("h2g2");
            request.SetCurrentUserNormal();

            request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=TestCreateCommentWithChangeSite&dnahostpageurl=" + hosturl + "&skin=purexml");
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();

            Assert.IsTrue(xml.SelectSingleNode("/H2G2/ERROR[@TYPE='commentfailed-invalidsite']") != null,"Error not created." );
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "0", "Comment appears to have been created from a different site.");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST") == null, "Post was created where it was not expected.");
          
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:29,代码来源:CommentBoxTests.cs

示例15: 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


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