• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Tests.DnaTestURLRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



DnaTestURLRequest类属于Tests命名空间,在下文中一共展示了DnaTestURLRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MakeUserEditorOfSite

        public void MakeUserEditorOfSite()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("moderation");
            request.SetCurrentUserSuperUser();

            DnaTestURLRequest request2 = new DnaTestURLRequest("moderation");
            request2.SetCurrentUserNormal();

            request.UseEditorAuthentication = true;
            request.RequestPage(String.Format("ModeratorManagement?manage=editor&giveaccess=1&userid={0}&siteid={1}&skin=purexml",request2.CurrentUserID,_siteId) );

            //Check user is editor of site concerned.
            XmlDocument xml = request.GetLastResponseAsXML();
            Assert.IsNotNull(xml.SelectSingleNode("/H2G2/MODERATOR-LIST[@GROUPNAME='editor']"));
            XmlNode node = xml.SelectSingleNode(String.Format("/H2G2/MODERATOR-LIST/MODERATOR[USER/USERID={0}]/SITES/SITE[@SITEID={1}]",request2.CurrentUserID,_siteId) );
            Assert.IsNotNull(node);

            
            CheckUserPermissions("EDITOR");
            

            //Remove Access
            request.RequestPage(String.Format("ModeratorManagement?manage=editor&removeaccess=1&userid={0}&siteid={1}&skin=purexml", request2.CurrentUserID, 1));
            xml = request.GetLastResponseAsXML();
            node = xml.SelectSingleNode(String.Format("/H2G2/MODERATOR-LIST/MODERATOR[USER/USERID={0}]/SITES/SITE[@SITEID={1}]", request2.CurrentUserID, 1));
            Assert.IsNull(node);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:27,代码来源:ModeratorManagementPageTests.cs


示例2: CreateAs_NormalUser

        public void CreateAs_NormalUser()
        {
            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(); // give it some sort of psot so that it uses POST, also see if it is interested in the POST data

            // create the pick

            myRequest.SetCurrentUserNormal();

            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,代码行数:33,代码来源:editorsPicksTests_v1.cs


示例3: Setup

        public void Setup()
        {
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                _appContext = new AppContext(TestConfig.GetConfig().GetRipleyServerPath());
                _siteOptionList = new SiteOptionList();
                _siteOptionList.CreateFromDatabase(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics);
            }
            
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();
            IInputContext inputContext = DnaMockery.CreateDatabaseInputContext();
            using (IDnaDataReader dataReader = inputContext.CreateDnaDataReader(""))
            {
                SetSiteID(dataReader, "h2g2");

                _includeContentFromOtherSites = _siteOptionList.GetValueBool(_siteId, "PersonalSpace", "IncludeContentFromOtherSites");

                //Create a post on h2g2
                SetForumID(dataReader);
                request = new DnaTestURLRequest("h2g2");
                request.SetCurrentUserNormal();
                int id = request.CurrentUserID;
                request.RequestPage("AddThread?subject=test&body=blahblah&post=1&skin=purexml&forum=" + Convert.ToString(_forumId));

                //Create a post on have your say.
                SetSiteID(dataReader, "haveyoursay");
                SetForumID(dataReader);
                request = new DnaTestURLRequest("haveyoursay");
                request.SetCurrentUserNormal();
                request.RequestPage("AddThread?subject=test&body=blahblah&post=1&skin=purexml&forum=" + Convert.ToString(_forumId));
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:33,代码来源:UserPageTests.cs


示例4: CreateEditorsPick

        public void CreateEditorsPick()
        {
            //First get a comment.
            CommentsTests_V1 comments = new CommentsTests_V1();
            CommentForumTests_V1 commentForums = new CommentForumTests_V1();

            _commentInfo = comments.CreateCommentHelper(commentForums.CommentForumCreateHelper().Id);

            Assert.IsNotNull(_commentInfo, "Unable to Create Comment");
            
            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserEditor();

             // Setup the request url
            string url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/comments/{1}/editorpicks/", _sitename,_commentInfo.ID);
            
            request.RequestPageWithFullURL(url, "No data to send", "text/xml");

            //Check for Editors Pick presence.
            url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/comments/?filterBy=EditorPicks", _sitename);
            request.RequestPageWithFullURL(url);

            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}']", _commentInfo.ID);
            XmlNode pick = xml.SelectSingleNode(xPath, nsmgr);
            Assert.IsNotNull(pick);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:30,代码来源:editorsPicks_v1.cs


示例5: bbActivateBoard

        public void bbActivateBoard()
        {
            aaCreateTopic();
            Console.WriteLine("Before bbActivateBoard");
            //Activate Board 
            string url = "Messageboardadmin?cmd=activateboard&skin=purexml";
            DnaTestURLRequest urlRequest = new DnaTestURLRequest("haveyoursay");
            urlRequest.SetCurrentUserEditor();
            urlRequest.UseEditorAuthentication = true;
            urlRequest.RequestPage(url);
            XmlDocument doc = urlRequest.GetLastResponseAsXML();

            Assert.IsNotNull(doc.SelectSingleNode("/H2G2[BOARDACTIVATED='1']"), "Check Board Activated");

            url = "frontpage?skin=purexml";
            urlRequest.RequestPage(url);
            doc = urlRequest.GetLastResponseAsXML();
            Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPICLIST/TOPIC[TITLE='" + topicName + "']"), "Check topic published");
            Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPICLIST/TOPIC[TOPICLINKID='" + topicPreviewID + "']"), "Check Preview Topic Link");
            XmlNode node = doc.SelectSingleNode("/H2G2/TOPICLIST/TOPIC[TITLE='" + topicName + "']/FORUMID");
            if (node != null)
            {
                topicForumID = node.InnerText;
            }

            //Check Topic Forum Is Writable.
            url = "F" + topicForumID + "&skin=purexml";
            urlRequest.RequestPage(url);
            doc = urlRequest.GetLastResponseAsXML();
            Assert.IsNotNull(doc.SelectSingleNode("/H2G2/FORUMSOURCE/ARTICLE/ARTICLEINFO[FORUMID='" + topicForumID + "']"), "Check Topic ForumId");
            Assert.IsNotNull(doc.SelectSingleNode("/H2G2/FORUMTHREADS[@CANREAD='1']"), "Check Read Permissions");
            Assert.IsNotNull(doc.SelectSingleNode("/H2G2/FORUMTHREADS[@CANWRITE='1']"), "Check Write Permissions");

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


示例6: TestComplaintBannedEmailIsCaughtUserNotLoggedIn

        public void TestComplaintBannedEmailIsCaughtUserNotLoggedIn()
        {
            // First make sure that the test user can make a complint before we put the email in the banned emails list
            DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
            request.SetCurrentUserNotLoggedInUser();
            request.RequestPage("UserComplaintPage?postid=1&skin=purexml");
            XmlDocument xml = request.GetLastResponseAsXML();

            // Check to make sure that no errors came back
            Assert.IsTrue(xml.SelectSingleNode("//USER-COMPLAINT-FORM/ERROR") == null, "There should not be any errors present in the XML!");

            // Now put the users email into the banned emails list for complaints if it's not already there
            IInputContext context = DnaMockery.CreateDatabaseInputContext();
            using (IDnaDataReader reader = context.CreateDnaDataReader("AddEMailToBannedList"))
            {
                reader.AddParameter("Email", "[email protected]");
                reader.AddParameter("SigninBanned", 0);
                reader.AddParameter("ComplaintBanned", 1);
                reader.AddParameter("EditorID", 6);
                reader.Execute();

                Assert.IsTrue(reader.HasRows, "No rows came back from the AddEMailToBannedList storedprocedure");
                Assert.IsTrue(reader.Read(), "Failed to read the first set of results from the AddEMailToBannedList storedprocedure");
                Assert.IsTrue(reader.Exists("Duplicate"), "The Duplicate result field is not in the AddEMailToBannedList dataset");
            }

            // Now try to complain again
            request.RequestPage("UserComplaintPage?postid=1&Submit=1&email=damnyoureyes72%[email protected]&skin=purexml");
            xml = request.GetLastResponseAsXML();

            // Check to make sure that no errors came back
            Assert.IsTrue(xml.SelectSingleNode("//ERROR") != null, "There should be an error present in the XML!");
            Assert.IsTrue(xml.SelectSingleNode("//ERROR[@TYPE='EMAILNOTALLOWED']") != null, "There should be an EMAILNOTALLOWED error present in the XML!");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:34,代码来源:BannedEMailsFunctionalTests.cs


示例7: EditPost_DoEdit_ReturnsEdittedPost

        public void EditPost_DoEdit_ReturnsEdittedPost()
        {
            DnaTestURLRequest request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserEditor();
            var xml = GetPost(request, @"editpost?skin=purexml&postid=" + _postId.ToString());

            Assert.IsNull(xml.SelectSingleNode("H2G2/ERROR"));
            Assert.IsNotNull(xml.SelectSingleNode("H2G2/POST-EDIT-FORM"));

            var editForm = (PostEditForm)StringUtils.DeserializeObjectUsingXmlSerialiser(xml.SelectSingleNode("H2G2/POST-EDIT-FORM").OuterXml, typeof(PostEditForm));
            Assert.AreEqual(_postId, editForm.PostId);

            var postParams = new Queue<KeyValuePair<string, string>>();
            postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("PostID", editForm.PostId.ToString()));
            postParams.Enqueue(new KeyValuePair<string, string>("Subject", editForm.Subject + "1"));
            postParams.Enqueue(new KeyValuePair<string, string>("Text", editForm.Text + "1"));
            postParams.Enqueue(new KeyValuePair<string, string>("Update", "Update"));
            postParams.Enqueue(new KeyValuePair<string, string>("hidePostReason", ""));
            postParams.Enqueue(new KeyValuePair<string, string>("notes", "test"));

            request.RequestPage("editpost?skin=purexml", false, postParams);
            xml = request.GetLastResponseAsXML();

            var returnedForm = (PostEditForm)StringUtils.DeserializeObjectUsingXmlSerialiser(xml.SelectSingleNode("H2G2/POST-EDIT-FORM").OuterXml, typeof(PostEditForm));
            Assert.AreEqual(_postId, returnedForm.PostId);
            Assert.AreEqual(editForm.Subject + "1", returnedForm.Subject);
            Assert.AreEqual(editForm.Text + "1", returnedForm.Text);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:29,代码来源:EditPostsPageTests.cs


示例8: aaCreateTopic

        public void aaCreateTopic()
        {
            Console.WriteLine("Before aaCreateTopic");
            topicName = "CreateTopic" + Convert.ToString(DateTime.Now.Ticks);
            string url = "TopicBuilder?_msfinish=yes&_msstage=1&_msxml=+%0D%0A%09%3CMULTI-INPUT%3E%0D%0A%09%09%3CREQUIRED+NAME%3D%27TITLE%27%3E%3CVALIDATE+TYPE%3D%27EMPTY%27+%2F%3E%3C%2FREQUIRED%3E%0D%0A%09%09%3CREQUIRED+NAME%3D%27TEXT%27%3E%3CVALIDATE+TYPE%3D%27EMPTY%27+%2F%3E%3C%2FREQUIRED%3E%0D%0A%09%09%3CREQUIRED+NAME%3D%27TEXTTYPE%27+%3E%3C%2FREQUIRED%3E%09%09%0D%0A%09%09%3CREQUIRED+NAME%3D%27TOPICID%27%3E%3C%2FREQUIRED%3E%09%0D%0A%09%09%3CREQUIRED+NAME%3D%27EDITKEY%27%3E%3C%2FREQUIRED%3E%09%0D%0A%09%3C%2FMULTI-INPUT%3E%0D%0A+&cmd=create&title=" + topicName + "&text=TestBody" + topicName + "&save=+save++&skin=purexml";
            DnaTestURLRequest urlRequest = new DnaTestURLRequest("haveyoursay");
            urlRequest.SetCurrentUserEditor();
            urlRequest.UseEditorAuthentication = true;
            urlRequest.RequestPage(url);
            XmlDocument doc = urlRequest.GetLastResponseAsXML();
            Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPIC_PAGE/ACTION[TYPE='created']"),"Check Topic Creation");
            Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPIC_PAGE/ACTION[OBJECT='" + topicName + "']"),"Check Topic Creation");
			Assert.IsNull(doc.SelectSingleNode("/H2G2/ERROR"),"Error in Page");

            XmlNode node = doc.SelectSingleNode("/H2G2/TOPIC_PAGE/TOPICLIST/TOPIC[TITLE='" + topicName + "']/EDITKEY");
            if ( node != null )
            {
                topicEditKey = node.InnerText;
            }

            node = doc.SelectSingleNode("/H2G2/TOPIC_PAGE/TOPICLIST/TOPIC[TITLE='" + topicName + "']/TOPICID");
            if ( node != null )
            {
                topicPreviewID = node.InnerText;
            }
            Console.WriteLine("After aaCreateTopic");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:27,代码来源:TopicBuilderTests.cs


示例9: missTrailingSlash

        public void missTrailingSlash()
        {
            Console.WriteLine("Before missingData - missTrailingSlash");

            // working data
            string id = "";
            string title = "";
            string parentUri = "";
            DnaTestURLRequest request = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);

            // fixed input data

            // test variant data
            string postData = testUtils_CommentsAPI.makePostXml(ref id, ref title, ref parentUri);
            string mimeType = "text/xml";
            string url = "http://" + testUtils_CommentsAPI.server + "/dna/api/comments/CommentsService.svc/v1/site/";
            HttpStatusCode expectedHttpResponse = HttpStatusCode.NotFound;

            request.SetCurrentUserEditor();

            try
            {
                request.RequestPageWithFullURL(url, postData, mimeType);
            }
            catch
            {// Check to make sure that the page returned with the correct information
            }

            Assert.IsTrue(request.CurrentWebResponse.StatusCode == expectedHttpResponse,
                "Expected "+expectedHttpResponse+", got " + request.CurrentWebResponse.StatusCode);

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


示例10: cPlusToApi

        public void cPlusToApi(){
            // Step 1. Try to create a comments forum using the API but as a normal user, should get unauthorised
            DnaTestURLRequest testUserReq = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);

            testUserReq.SetCurrentUserNormal();

            testUserReq = createForum(testUserReq, HttpStatusCode.Unauthorized); // will crash the test if it does not get the right status

            // Step 2. Use the Inspect User page (a C++ page) to update the user's groups
            setEdStatusCplus(testUserReq, true);

            Thread.Sleep(5000);

            // Step 3. Remove trace of this from the database, so that we can see that there is some caching somewhere
            clearFromDB(testUserReq);

            // Step 4. Try creating a comment forum again, should succeed because now the test user is an editor on the globally named site
            testUserReq = createForum(testUserReq, HttpStatusCode.OK);

            //// Step 5. Use the Inspect User page (a C++ page) to update the user's groups
            //setEdStatusCplus(testUserReq, false);

            ////Thread.Sleep(5000);

            //// Step 6. Remove trace of this from the database
            //clearFromDB(testUserReq);

            //// Step 7. try creating a comment forum again, shuould succeed because now the test user is an editor on the globally named site
            //testUserReq = createForum(testUserReq, HttpStatusCode.Unauthorized); // will crash the test if it does not get the right status


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


示例11: NoData

        public void NoData()
        {
            Console.WriteLine("Before missingData - NoData");

            // test variant data
            string postData = "";
            string mimeType = "";
            string url = "http://" + testUtils_CommentsAPI.server + "/dna/api/comments/CommentsService.svc/v1/site/";
            //HttpStatusCode expectedHttpResponse = HttpStatusCode.OK;

            // consistent input data

            // working data
            DnaTestURLRequest request = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
            request.SetCurrentUserEditor();

            // now get the response - no POST data, nor any clue about the type
            try
            {
                request.RequestPageWithFullURL(url, postData, mimeType);
            }
            catch
            {// Check to make sure that the page returned with the correct information
                Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.NotFound);
            }
            Console.WriteLine("After missingData - NoData");
        } // ends NoData
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:27,代码来源:missingData_v1.cs


示例12: DuplicatePostParams

        public void DuplicatePostParams()
        {
            Console.WriteLine("DuplicatePostParams");
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");

            Queue<KeyValuePair<string, string>> postparams = new Queue<KeyValuePair<string, string> >();
            postparams.Enqueue(new KeyValuePair<string,string>("s_param", "1,1"));
            postparams.Enqueue(new KeyValuePair<string,string>("s_param", "2,2"));
            postparams.Enqueue(new KeyValuePair<string,string>("s_param", "3,3"));
            request.RequestPage("acs?skin=purexml", postparams);

            string paramvalue = "1,1,2,2,3,3";
            XmlDocument doc = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(doc.InnerXml, "H2G2CommentBoxFlat.xsd");
            validator.Validate();

            validator = new DnaXmlValidator(doc.SelectSingleNode(@"H2G2/PARAMS").OuterXml, "Params.xsd");
            validator.Validate();

            XmlNodeList nodes = doc.SelectNodes(@"H2G2/PARAMS/PARAM");
            foreach (XmlNode node in nodes)
            {
                Assert.AreEqual(paramvalue, node.SelectSingleNode("VALUE").InnerText);
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:25,代码来源:RequestParameterTests.cs


示例13: TestModerationEvent

        public void TestModerationEvent()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("moderation");
            request.SetCurrentUserModerator();

            //Put an item into moderation queue and moderate it.
            IInputContext context = DnaMockery.CreateDatabaseInputContext();
            String sql = String.Format("EXECUTE addexlinktomodqueue @siteid={0}, @uri='{1}', @callbackuri='{2}', @notes='{3}'",1, "http://localhost:8089/", "http://localhost:8089/", "Test");
            int modId = 0;
            using (IDnaDataReader dataReader = context.CreateDnaDataReader(sql))
            {
                dataReader.ExecuteDEBUGONLY(sql);

                dataReader.ExecuteDEBUGONLY(String.Format("EXEC getmoderationexlinks @modclassid=0, @referrals=0,@alerts=0, @locked=0, @userid={0}", request.CurrentUserID));
                dataReader.Read();
                modId = dataReader.GetInt32NullAsZero("modid");

                dataReader.ExecuteDEBUGONLY(String.Format("EXECUTE moderateexlinks @modid={0}, @userid={1},@decision={2},@notes='{3}',@referto={4}", modId, request.CurrentUserID, 3, "Testing", 0));
            
                //Process Event Queue 
                dataReader.ExecuteDEBUGONLY("EXECUTE processeventqueue");
            }

            //Wait up to 10 seconds for callback.
            if (_thread.IsAlive)
            {
                _thread.Join(60000);
            }

            //Check Moderation Item has been processed.
            Assert.IsTrue( _callbackBody.Contains(Convert.ToString(modId)),"Checking value of returned ModId. In order for this test to work the SNESEventProcessor Service must be running against Small Guide.");

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


示例14: FileUploadRequest

        public void FileUploadRequest()
        {
            Console.WriteLine("FileUploadRequest");
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");

            Queue<KeyValuePair<string, string>> postparams = new Queue<KeyValuePair<string, string>>();
            postparams.Enqueue(new KeyValuePair<string, string>("skin", "purexml"));
            postparams.Enqueue(new KeyValuePair<string, string>("s_param", "1,1"));
            postparams.Enqueue(new KeyValuePair<string, string>("s_param", "2,2"));
            postparams.Enqueue(new KeyValuePair<string, string>("s_param", "3,3"));
            
            string uploadfile;// set to file to upload
            uploadfile = GetTestFile();

            //everything except upload file and url can be left blank if needed
            request.UploadFileEx(uploadfile, "acs", "image/jpeg",postparams,new CookieContainer());


            //Check Parameters parsed OK.
            string paramvalue = "1,1,2,2,3,3";
            XmlDocument doc = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(doc.InnerXml, "H2G2CommentBoxFlat.xsd");
            validator.Validate();

            validator = new DnaXmlValidator(doc.SelectSingleNode(@"H2G2/PARAMS").OuterXml, "Params.xsd");
            validator.Validate();

            XmlNodeList nodes = doc.SelectNodes(@"H2G2/PARAMS/PARAM");
            foreach (XmlNode node in nodes)
            {
                Assert.AreEqual(paramvalue, node.SelectSingleNode("VALUE").InnerText);
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:33,代码来源:RequestParameterTests.cs


示例15: SyncUserDetailsViaBBCDna

        public void SyncUserDetailsViaBBCDna()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("identity606");
            request.SetCurrentUserAsNewIdentityUser(_userName, _password, _displayName, _email, _dob, TestUserCreator.IdentityPolicies.Adult, "identity606", TestUserCreator.UserType.IdentityOnly);
            string cookie = request.CurrentCookie;
            request.RequestPage("status-n?skin=purexml");
            XmlDocument doc = request.GetLastResponseAsXML();

            Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME"), "User name is not correct");
            Assert.AreEqual(_displayName, doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME").InnerText, "User name is not correct");
            Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME"), "login name is not correct");
            Assert.AreEqual(_userName, doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME").InnerText, "login name is not correct");
            Assert.IsNull(doc.SelectSingleNode("//VIEWING-USER/USER/FIRSTNAME"), "There shouldn't be a first name");
            Assert.IsNull(doc.SelectSingleNode("//VIEWING-USER/LASTNAME"), "There shouldn't be a last name");
            Thread.Sleep(2000);

            Assert.IsTrue(TestUserCreator.SetIdentityAttribute(_userName, cookie, TestUserCreator.AttributeNames.DisplayName, _displayName));
            Assert.IsTrue(TestUserCreator.SetIdentityAttribute(_userName, cookie, TestUserCreator.AttributeNames.FirstName, _firstName));
            Assert.IsTrue(TestUserCreator.SetIdentityAttribute(_userName, cookie, TestUserCreator.AttributeNames.LastName, _lastName));
            Assert.IsTrue(TestUserCreator.SetIdentityAttribute(_userName, cookie, TestUserCreator.AttributeNames.Email, _newEmail));
            
            request.RequestPage("status-n?skin=purexml");

            doc = request.GetLastResponseAsXML();
            Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME"), "User name is not correct");
            Assert.AreEqual(_displayName, doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME").InnerText, "User name is not correct");
            Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME"), "login name is not correct");
            Assert.AreEqual(_userName, doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME").InnerText, "login name is not correct");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:29,代码来源:UserSynchronisationTests.cs


示例16: CreateTestCommentForum

        public static void CreateTestCommentForum(DnaTestURLRequest request, bool allowAnonymousPosting, string title, string id)
        {
            SetSiteOptionForAnonymousPosting(request, allowAnonymousPosting);

            string text = "Lets Start this test with " + DateTime.Now.Ticks;
            string parentUri = "http://local.bbc.co.uk/dna/h2g2";

            CommentForum postDataForum = CreateCommentforumToPost(allowAnonymousPosting, title, id, text, parentUri, "First Poster");
            TestRunnerManager.GetTestRunner().ScenarioContext.Add("CreateTestCommentForum.newCommentForum", postDataForum);

            try
            {
                string jsonPostData = SerializeToJsonString(postDataForum);
                CommentForumTestUtils.CallPUTCreateCommentAPIRequest(request, "h2g2", id, jsonPostData, DnaTestURLRequest.usertype.NOTLOGGEDIN);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (allowAnonymousPosting)
                {
                    Console.WriteLine(ex.StackTrace);
                    throw ex;
                }
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:25,代码来源:CommentForumTestUtils.cs


示例17: TermsFilterAdminPage_UpdateExistingTerm_CorrectlyUpdates

        public void TermsFilterAdminPage_UpdateExistingTerm_CorrectlyUpdates()
        {
            const int modClassId = 2;
            var request = new DnaTestURLRequest(SiteName) { UseEditorAuthentication = true };
            request.SetCurrentUserSuperUser();
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&skin=purexml", modClassId));
            ValidateResponse(request);

            var doc = request.GetLastResponseAsXML();
            var termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS");
            var termText = termNode.Attributes["TERM"].Value;
            var action = (TermAction) Enum.Parse(typeof (TermAction), termNode.Attributes["ACTION"].Value);
            TermAction expectedAction = (action == TermAction.ReEdit ? TermAction.Refer : TermAction.ReEdit);

            var postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("termtext",termText));
            postParams.Enqueue(new KeyValuePair<string, string>("termaction", expectedAction.ToString()));

            //update the first term
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&action=UPDATETERM&skin=purexml", modClassId),
                postParams);

            ValidateResponse(request);
            ValidateOkResult(request, "TermsUpdateSuccess", "Terms updated successfully.");
            doc = request.GetLastResponseAsXML();
            termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS");
            Assert.AreEqual(expectedAction.ToString(), termNode.Attributes["ACTION"].Value);
            Assert.AreEqual(termText, termNode.Attributes["TERM"].Value);

            //check history audit
            var terms = new List<Term>();
            terms.Add(new Term { Id = Int32.Parse(termNode.Attributes["ID"].Value), Action = expectedAction});
            CheckAuditTable(modClassId, terms);

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


示例18: countForums

        public static int runningForumCount = 0; // used to see our starting count, before we start adding forums.

        /// <summary>
        /// Simply count the number of commentsForums that have been created so far on this site
        /// </summary>
        /// <param name="SiteName">the name of the sute to query</param>
        /// <returns>teh count</returns>
        public static int countForums(string SiteName)
        {
            string _server = DnaTestURLRequest.CurrentServer;

            DnaTestURLRequest request = new DnaTestURLRequest(SiteName);

            request.SetCurrentUserNormal();

            // Setup the request url
            string url = "http://" + _server + "/dna/api/comments/CommentsService.svc/v1/site/" + SiteName + "/";

            // now get the response - no POST data, nor any clue about the input mime-type
            request.RequestPageWithFullURL(url, "", "");

            Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.OK);

            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForumList);
            validator.Validate();

            BBC.Dna.Api.CommentForumList returnedList = (BBC.Dna.Api.CommentForumList)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.CommentForumList));
            Assert.IsTrue(returnedList != null);

            return returnedList.TotalCount;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:32,代码来源:TestUtils_commentsAPI.cs


示例19: UserListTests

        /// <summary>
        /// Constructor for the User Tests to set up the context for the tests
        /// </summary>
        public UserListTests()
        {
            string rootPath = TestConfig.GetConfig().GetRipleyServerPath();
            BBC.Dna.AppContext.OnDnaStartup(rootPath);


            Console.WriteLine("Before RecentSearch - AddRecentSearchTests");

            //Create the mocked _InputContext
            Mockery mock = new Mockery();
            _InputContext = DnaMockery.CreateDatabaseInputContext();

            // Create a mocked site for the context
            ISite mockedSite = DnaMockery.CreateMockedSite(_InputContext, 1, "h2g2", "h2g2", true, "comment");
            Stub.On(_InputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));
            Stub.On(mockedSite).GetProperty("ModClassID").Will(Return.Value(1));


            BBC.Dna.User user = new BBC.Dna.User(_InputContext);
            Stub.On(_InputContext).GetProperty("ViewingUser").Will(Return.Value(user));
            Stub.On(_InputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));

            //Create sub editor group and users
            //create test sub editors
            DnaTestURLRequest dnaRequest = new DnaTestURLRequest("h2g2");
            dnaRequest.SetCurrentUserEditor();
            TestDataCreator testData = new TestDataCreator(_InputContext);
            int[] userIDs = new int[10];
            Assert.IsTrue(testData.CreateNewUsers(mockedSite.SiteID, ref userIDs), "Test users not created");
            Assert.IsTrue(testData.CreateNewUserGroup(dnaRequest.CurrentUserID, "subs"), "CreateNewUserGroup not created");
            Assert.IsTrue(testData.AddUsersToGroup(userIDs, mockedSite.SiteID, "subs"), "Unable to add users to group not created");


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


示例20: CreateAs_NormalUser

        public void CreateAs_NormalUser()
        {
            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(); // give it some sort of psot so that it uses POST, also see if it is interested in the POST data

            // create the pick

            myRequest.SetCurrentUserNormal();

            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,代码行数:30,代码来源:editorsPicksTests_v1.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Tests.DnaXmlValidator类代码示例发布时间:2022-05-26
下一篇:
C# Python.PythonVisualStudioApp类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap