本文整理汇总了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");
}