本文整理汇总了C#中Tests.DnaTestURLRequest.SetCurrentUserTrustedUser方法的典型用法代码示例。如果您正苦于以下问题:C# DnaTestURLRequest.SetCurrentUserTrustedUser方法的具体用法?C# DnaTestURLRequest.SetCurrentUserTrustedUser怎么用?C# DnaTestURLRequest.SetCurrentUserTrustedUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tests.DnaTestURLRequest
的用法示例。
在下文中一共展示了DnaTestURLRequest.SetCurrentUserTrustedUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateComment_AsTrustedUser
public void CreateComment_AsTrustedUser()
{
var request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserTrustedUser();
//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);
// Setup the request url
string 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, commentForumXml, "text/xml");
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
//check the TextAsHtml element
//string textAsHtml = xml.DocumentElement.ChildNodes[2].InnerXml;
//Assert.IsTrue(textAsHtml == "<div class=\"dna-comment text\" xmlns=\"\">" + text + "</div>");
CommentInfo returnedComment = (CommentInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentInfo));
Assert.IsTrue(returnedComment.text == text);
Assert.IsNotNull(returnedComment.User);
Assert.IsTrue(returnedComment.User.UserId == request.CurrentUserID);
DateTime created = DateTime.Parse(returnedComment.Created.At);
DateTime createdTest = BBC.Dna.Utils.TimeZoneInfo.GetTimeZoneInfo().ConvertUtcToTimeZone(DateTime.Now.AddMinutes(5));
Assert.IsTrue(created < createdTest);//should be less than 5mins
Assert.IsTrue(!String.IsNullOrEmpty(returnedComment.Created.Ago));
}