本文整理匯總了C#中Tests.DnaTestURLRequest.GetLastResponseAsXML方法的典型用法代碼示例。如果您正苦於以下問題:C# DnaTestURLRequest.GetLastResponseAsXML方法的具體用法?C# DnaTestURLRequest.GetLastResponseAsXML怎麽用?C# DnaTestURLRequest.GetLastResponseAsXML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tests.DnaTestURLRequest
的用法示例。
在下文中一共展示了DnaTestURLRequest.GetLastResponseAsXML方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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");
}
示例2: 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);
}
示例3: Messageboardschedule_CloseSiteInDB_CheckClosedInCSharp
public void Messageboardschedule_CloseSiteInDB_CheckClosedInCSharp()
{
Console.WriteLine("TestCodeSignalSendToRecacheSiteListDataViaDotNet");
// Get the current open and close times for the h2g2 site
DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
request.RequestPage("acs?skin=purexml");
Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null);
Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "0");
// Now check to make sure that the XML for the sitelist has not changed
request.RequestPage("?skin=purexml");
Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null);
Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "0");
// Now set the site to be closed
Assert.IsTrue(SetSiteEmergencyClosed(true), "Failed to close h2g2");
// Now check to make sure that the XML for the sitelist has not changed
request.RequestPage("acs?skin=purexml");
Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null);
Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "0");
// Now check to make sure that the XML for the sitelist has not changed
request.RequestPage("?skin=purexml");
Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null);
Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "0");
// Now send the recache signal and check to make sure that the times are updated!
using (FullInputContext inputContext = new FullInputContext(false))
{
inputContext.SendSignal("action=recache-site");
// Now check to make sure that the XML for the sitelist has not changed
request.RequestPage("acs?skin=purexml");
Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null);
Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "1");
// Now check to make sure that the XML for the sitelist has not changed
request.RequestPage("?skin=purexml");
Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null);
Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "1");
// Now set the site to be open
Assert.IsTrue(SetSiteEmergencyClosed(false), "Failed to open h2g2");
// Double check to make sure it's back to normal
// Now send the recache signal and check to make sure that the times are updated!
inputContext.SendSignal("action=recache-site");
}
// Now check to make sure that the closed value has been put back correctly
request.RequestPage("acs?skin=purexml");
Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null);
Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "0");
// Now check to make sure that the closed value has been put back correctly
request.RequestPage("?skin=purexml");
Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null);
Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "0");
}
示例4: TestComplaintBannedEmailIsCaught
public void TestComplaintBannedEmailIsCaught()
{
// 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.SetCurrentUserNormal();
int userID = request.CurrentUserID;
request.RequestPage("UserComplaintPage?postid=2&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!");
try
{
// Now put the users email into the banned emails list for complaints
IInputContext context = DnaMockery.CreateDatabaseInputContext();
using (IDnaDataReader reader = context.CreateDnaDataReader("AddEMailToBannedList"))
{
reader.AddParameter("Email", "[email protected]");//this is dotnetnormaluser's email
reader.AddParameter("SigninBanned", 0);
reader.AddParameter("ComplaintBanned", 1);
reader.AddParameter("EditorID", 6);
reader.AddIntReturnValue();
reader.Execute();
var duplicate = reader.GetIntReturnValue();
Assert.AreEqual(0, duplicate, "The Duplicate result should be false (0)");
request.RequestPage("dnasignal?action=recache-bannedEmails");
}
// Now try to complain again
request.RequestPage("UserComplaintPage?postid=2&skin=purexml");
request.SetCurrentUserEditor();
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!");
}
finally
{
IInputContext context = DnaMockery.CreateDatabaseInputContext();
using (IDnaDataReader reader = context.CreateDnaDataReader(""))
{
reader.ExecuteDEBUGONLY("exec removebannedemail @email='[email protected]'");//this is dotnetnormaluser's email
request.RequestPage("dnasignal?action=recache-bannedEmails");
}
}
}
示例5: 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);
}
示例6: 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");
}
示例7: 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");
}
示例8: 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);
}
}
示例9: 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;
}
示例10: 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);
}
示例11: Test1CreateForumWithNoCloseDate
public void Test1CreateForumWithNoCloseDate()
{
Console.WriteLine("Before CommentForumClosingDateTests - Test1CreateForumWithNoCloseDate");
// Create a new comment box with no closing date
DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
request.SetCurrentUserNormal();
// Setup the request url
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 + "&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.OuterXml, _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='1']") != null, "The forums can write flag should be set 1");
Console.WriteLine("After CommentForumClosingDateTests - Test1CreateForumWithNoCloseDate");
}
示例12: TermsFilterImportPage_WithoutEditorAuthenticationAsInSecured_AccessDenied
public void TermsFilterImportPage_WithoutEditorAuthenticationAsInSecured_AccessDenied()
{
var siteName = "moderation";
var request = new DnaTestURLRequest(siteName) { UseEditorAuthentication = false, UseDebugUserSecureCookie=false};
request.SetCurrentUserSuperUser();
request.RequestPage("termsfilterimport?&skin=purexml", false, null);
var xml = request.GetLastResponseAsXML();
Assert.AreEqual("ERROR", xml.DocumentElement.Attributes[0].Value);
}
示例13: TestModeratorManagementPageNonSuperuser
public void TestModeratorManagementPageNonSuperuser()
{
DnaTestURLRequest request = new DnaTestURLRequest("moderation");
request.SetCurrentUserNormal();
request.UseEditorAuthentication = true;
request.RequestPage(@"ModeratorManagement?skin=purexml");
XmlDocument xml = request.GetLastResponseAsXML();
Assert.IsNotNull(xml.SelectSingleNode("H2G2/ERROR"));
}
示例14: TestModeratePostsPageNonModerator
public void TestModeratePostsPageNonModerator()
{
DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
request.SetCurrentUserNormal();
request.UseEditorAuthentication = true;
request.RequestPage(@"ModeratePosts?modclassid=1&skin=purexml");
XmlDocument xml = request.GetLastResponseAsXML();
Assert.IsNotNull(xml.SelectSingleNode("H2G2/ERROR"));
}
示例15: inXMLoutXML
public void inXMLoutXML()
{
Console.WriteLine("Before formatParamTests - inXMLoutXML");
// test variant data
string mimeType = "text/xml";
string formatParam = "XML";
HttpStatusCode expectedResponseCode = HttpStatusCode.OK;
// working data
string id = "";
string title = "";
string parentUri = "";
// make the post as XML data
string postData = testUtils_ratingsAPI.makeCreatePostXml_minimal(ref id, ref title, ref parentUri);
string url = testUtils_ratingsAPI.makeCreateForumUrl() + "?format=" + formatParam;
DnaTestURLRequest request = new DnaTestURLRequest(testUtils_ratingsAPI.sitename);
request.SetCurrentUserEditor();
try
{
request.RequestPageWithFullURL(url, postData, mimeType);
}
catch
{
string resp = request.GetLastResponseAsString(); // usefull when debugging
if (expectedResponseCode == HttpStatusCode.OK)
Assert.Fail("Fell over: " + resp);
}
Assert.IsTrue(
request.CurrentWebResponse.StatusCode == expectedResponseCode,
"HTTP repsonse. Expected:" + expectedResponseCode + " actually got " + request.CurrentWebResponse.StatusCode
);
XmlDocument xml = request.GetLastResponseAsXML();
DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, testUtils_ratingsAPI._schemaRatingForum);
validator.Validate();
BBC.Dna.Api.RatingForum returnedForum =
(BBC.Dna.Api.RatingForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.RatingForum)
);
Assert.IsTrue(returnedForum.Id == id);
Assert.IsTrue(returnedForum.Title == title);
Assert.IsTrue(returnedForum.ParentUri == parentUri);
Assert.IsTrue(returnedForum.ratingsList.TotalCount == 0);
Console.WriteLine("After formatParamTests - inXMLoutXML");
} // ends inXMLoutXML