本文整理汇总了C#中Tests.DnaTestURLRequest.AddCookie方法的典型用法代码示例。如果您正苦于以下问题:C# DnaTestURLRequest.AddCookie方法的具体用法?C# DnaTestURLRequest.AddCookie怎么用?C# DnaTestURLRequest.AddCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tests.DnaTestURLRequest
的用法示例。
在下文中一共展示了DnaTestURLRequest.AddCookie方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateComment_IPAndBBCUID
public void CreateComment_IPAndBBCUID()
{
Console.WriteLine("Before CreateComment");
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
//create the forum
CommentForum commentForum = CommentForumCreate("tests", Guid.NewGuid().ToString());
string text = "Functiontest Title" + Guid.NewGuid().ToString();
string commentForumXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
"<text>{0}</text>" +
"</comment>", text);
string ipAddr = "123.234.111.222";
var bbcUid = "a49ff1bd14e116a4ea40f185d1e4cb22b92044cc07980e37bd71359ac99014d80Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.";
var bbcUidCookie = new Cookie("BBC-UID", HttpUtility.UrlEncode(bbcUid));
request.AddCookie(bbcUidCookie);
// Setup the request url
string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?format=JSON&clientIp={2}", _sitename, commentForum.Id, ipAddr);
// now get the response
request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
Assert.AreEqual("application/json", request.CurrentWebResponse.ContentType);
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader dataReader = inputcontext.CreateDnaDataReader(""))
{
dataReader.ExecuteDEBUGONLY(@"
select top 1 * from threadentries te
left join threadentriesipaddress teip on teip.entryid=te.entryid
order by te.entryid desc");
Assert.IsTrue(dataReader.Read());
Assert.AreEqual(ipAddr, dataReader.GetString("IPAddress"));
Assert.AreEqual(UidCookieDecoder.Decode(bbcUid, ""), dataReader.GetGuid("BBCUID"));
}
}
}
示例2: CreateCommentAndRateDownAsAnonymousUserAndValidate
private void CreateCommentAndRateDownAsAnonymousUserAndValidate(int apiVersion)
{
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
CommentForum commentForum = new CommentForum();
CommentInfo commentInfo = new CommentInfo();
CreateTestForumAndComment(ref commentForum, ref commentInfo);
try
{
SetSiteOption(1, "CommentForum", "AllowNotSignedInRating", 1, "1");
request.AddCookie(new Cookie("BBC-UID", "a4acfefaf9d7a374026abfa9419a957ae48c5e5800803144642fba8aadcff86f0Mozilla%2f5%2e0%20%28Windows%3b%20U%3b%20Windows%20NT%205%2e1%3b%20en%2dGB%3b%20rv%3a1%2e9%2e2%2e12%29%20Gecko%2f20101026%20Firefox%2f3%2e6%2e12%20%28%2eNET%20CLR%203%2e5%2e30729%29"));
string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V{3}/site/{0}/commentsforums/{1}/comment/{2}/rate/down?clientIp=1.1.1.1", _sitename, commentForum.Id, commentInfo.ID, apiVersion);
// now get the response
request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
if (apiVersion == 1)
{
Assert.AreEqual("-1", xml.DocumentElement.InnerText);
}
else if (apiVersion == 2)
{
var neroRatingInfo = (NeroRatingInfo)StringUtils.DeserializeObject(xml.InnerXml, typeof(NeroRatingInfo));
Assert.AreEqual(-1, neroRatingInfo.neroValue);
Assert.AreEqual(0, neroRatingInfo.positiveNeroValue);
Assert.AreEqual(-1, neroRatingInfo.negativeNeroValue);
}
else
{
Assert.Fail("We don't support any other version than 1 or 2");
}
url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/", _sitename, commentForum.Id);
// now get the response
request.RequestPageWithFullURL(url, null, "text/xml");
xml = request.GetLastResponseAsXML();
var validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
var returnedForum = (CommentForum)StringUtils.DeserializeObject(xml.InnerXml, typeof(CommentForum));
Assert.AreEqual(-1, returnedForum.commentList.comments[0].NeroRatingValue);
Assert.AreEqual(0, returnedForum.commentList.comments[0].NeroPositiveRatingValue);
Assert.AreEqual(-1, returnedForum.commentList.comments[0].NeroNegativeRatingValue);
}
finally
{
RemoveSiteOption(1, "AllowNotSignedInRating");
}
}