本文整理匯總了C#中Tests.DnaTestURLRequest.ClearCookieContainer方法的典型用法代碼示例。如果您正苦於以下問題:C# DnaTestURLRequest.ClearCookieContainer方法的具體用法?C# DnaTestURLRequest.ClearCookieContainer怎麽用?C# DnaTestURLRequest.ClearCookieContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tests.DnaTestURLRequest
的用法示例。
在下文中一共展示了DnaTestURLRequest.ClearCookieContainer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateCommentForum_CreateCommentAsNonAgreedTermsAndConditionsUser
public void CreateCommentForum_CreateCommentAsNonAgreedTermsAndConditionsUser()
{
Console.WriteLine("Before CreateCommentAsNonAgreedTermsAndConditionsUser");
var request = new DnaTestURLRequest("identity606");
string userName = "CommentForumCreateUser" + DateTime.Now.Ticks;
string userEmail = userName + "@bbc.co.uk";
request.SetCurrentUserSuperUser();
/*
Assert.IsTrue(
request.SetCurrentUserAsNewIdentityUser(userName, "password", "Comment User", userEmail, "1989-12-31",
TestUserCreator.IdentityPolicies.Adult, "identity606",
TestUserCreator.UserType.SuperUser),
"Failed to create a test identity user");
*/
string id = "FunctiontestCommentForum-" + Guid.NewGuid(); //have to randomize the string to post
string title = "Functiontest Title";
string parentUri = "http://www.bbc.co.uk/dna/h2g2/";
string commentForumXml = String.Format("<commentForum xmlns=\"BBC.Dna.Api\">" +
"<id>{0}</id>" +
"<title>{1}</title>" +
"<parentUri>{2}</parentUri>" +
"</commentForum>", id, title, parentUri);
// Setup the request url
string url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/",
"identity606");
try
{
// now get the response
request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
}
catch
{
}
;
Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.OK);
userName = "CommentCreateUser" + DateTime.Now.Ticks;
userEmail = userName + "@bbc.co.uk";
//Assert.IsTrue(request.SetCurrentUserAsNewIdentityUser(userName, "password", "Comment User", userEmail, "1989-12-31", TestUserCreator.IdentityPolicies.Adult, true, false, 1, false), "Failed to create a test identity user");
Cookie cookie;
Cookie secureCookie;
string identityUserID;
Assert.IsTrue(TestUserCreator.CreateIdentityUser(userName, "password", "1989-12-31", userEmail,
"Comment User", true,
TestUserCreator.IdentityPolicies.Adult, false, 0,
out cookie,
out secureCookie,
out identityUserID));
request.UseDebugUser = false;
request.ClearCookieContainer();
request.UseIdentitySignIn = true;
request.CurrentCookie = cookie.Value;
request.CurrentSecureCookie = secureCookie.Value;
string text = "Functiontest Title" + Guid.NewGuid();
commentForumXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
"<text>{0}</text>" +
"</comment>", text);
// Setup the comment request url - needs to be secure
url =
String.Format(
"https://" + _secureServer + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/",
"identity606", id);
try
{
// now get the response
request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
}
catch
{
}
;
Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.Unauthorized);
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("bda", "BBC.Dna.Api");
Assert.IsNotNull(xml.SelectSingleNode("//bda:error/bda:code", nsmgr), "Failed to find the error code");
Assert.AreEqual("FailedTermsAndConditions", xml.SelectSingleNode("//bda:error/bda:code", nsmgr).InnerText);
Assert.IsNotNull(xml.SelectSingleNode("//bda:error/bda:detail", nsmgr), "Failed to find the error deatils");
Assert.AreEqual("comment",
xml.SelectSingleNode("//bda:error/bda:detail", nsmgr).InnerText);
Console.WriteLine("After CreateCommentAsNonAgreedTermsAndConditionsUser");
}