本文整理汇总了C#中BBC.Dna.Api.CommentForum类的典型用法代码示例。如果您正苦于以下问题:C# CommentForum类的具体用法?C# CommentForum怎么用?C# CommentForum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommentForum类属于BBC.Dna.Api命名空间,在下文中一共展示了CommentForum类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CommentForum_BasicAddCommentWithStatsCheck
public void CommentForum_BasicAddCommentWithStatsCheck()
{
CommentForum commentForum = new CommentForum
{
Id = Guid.NewGuid().ToString(),
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
CommentForum result = CreateForum(commentForum);
Assert.IsTrue(result != null);
Assert.IsTrue(result.commentSummary.Total == 0);
//add a comment
CommentInfo comment = new CommentInfo { text = "this is a nunit generated comment." + Guid.NewGuid().ToString() };
CreateComment(comment, result);
//get forum again
result = ReadForum(result.Id);
Assert.IsTrue(result != null);
Assert.IsTrue(result.commentSummary.Total == 1);
XmlDocument xStats = GetAllStatCounter();
Assert.IsTrue(GetStatCounter(xStats, "RAWREQUESTS") == 3);
//get forum again
result = ReadForum(result.Id);
Assert.IsTrue(result != null);
Assert.IsTrue(result.commentSummary.Total == 1);
xStats = GetAllStatCounter();
Assert.IsTrue(GetStatCounter(xStats, "RAWREQUESTS") == 4);
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:34,代码来源:CommentForumCachingAndStats.cs
示例2: StartUp
public void StartUp()
{
SnapshotInitialisation.RestoreFromSnapshot();
_context = new FullInputContext("");
_siteList = _context.SiteList;
// Create a comment forums to post tweets to, and the corresponding URLs
CommentsTests_V1 ct = new CommentsTests_V1();
_commentForumReactive = ct.CommentForumCreate("Tests Reactive", Guid.NewGuid().ToString(),ModerationStatus.ForumStatus.Reactive);
_tweetPostUrlReactive= String.Format("http://" + _server + "/dna/api/comments/TwitterService.svc/V1/site/{0}/commentsforums/{1}/",_sitename, _commentForumReactive.Id);
_commentForumPremod = ct.CommentForumCreate("Tests Premod", Guid.NewGuid().ToString(),ModerationStatus.ForumStatus.PreMod);
_tweetPostUrlPremod = String.Format("http://" + _server + "/dna/api/comments/TwitterService.svc/V1/site/{0}/commentsforums/{1}/", _sitename, _commentForumPremod.Id);
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:15,代码来源:TwitterTests.cs
示例3: CreateCommentforumToPost
public static CommentForum CreateCommentforumToPost(bool allowAnonymousPosting, string title, string id, string text, string parentUri, string userName)
{
CommentForum postDataForum = new CommentForum();
postDataForum.ParentUri = parentUri;
postDataForum.Title = title;
postDataForum.Id = id;
postDataForum.allowNotSignedInCommenting = allowAnonymousPosting;
postDataForum.commentList = new CommentsList();
postDataForum.commentList.comments = new List<CommentInfo>();
CommentInfo testCommentInfo = new CommentInfo();
testCommentInfo.text = text;
testCommentInfo.User.DisplayName = userName;
postDataForum.commentList.comments.Add(testCommentInfo);
return postDataForum;
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:15,代码来源:CommentForumTestUtils.cs
示例4: CreateTestForumAndComment
public void CreateTestForumAndComment(ref CommentForum commentForum, ref CommentInfo returnedComment)
{
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
//create the forum
if(string.IsNullOrEmpty(commentForum.Id))
{
commentForum = commentsHelper.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>");
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));
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:38,代码来源:CommentsNeroRatings_v1.cs
示例5: CommentListReadByUID_SortBy_Created
public void CommentListReadByUID_SortBy_Created()
{
string uid = "testCommentForum_CommentListReadBySiteName" + Guid.NewGuid().ToString();
CommentForum commentForum = new CommentForum
{
Id = uid,
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
//create the forum
CommentForum result = _comments.CreateCommentForum(commentForum, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
//create the comment
//set up test data
for (int i = 0; i < 10; i++)
{
CommentInfo comment = new CommentInfo
{
text = "this is a nunit generated comment."
};
comment.text += Guid.NewGuid().ToString();//have to randomize the string to post
string IPAddress = String.Empty;
Guid BBCUid = Guid.NewGuid();
//normal user
_comments.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetNormalUserAccount.UserName, _siteList);
_comments.CallingUser.CreateUserFromDnaUserID(TestUtils.TestUserAccounts.GetNormalUserAccount.UserID, site.SiteID);
CommentInfo commentInfo = _comments.CreateComment(result, comment);
Assert.IsTrue(commentInfo != null);
Assert.IsTrue(commentInfo.ID > 0);
Assert.IsTrue(commentInfo.text == comment.text);
}
//test good site
CommentForum resultList = _comments.GetCommentForumByUid(uid, site);
Assert.IsTrue(resultList != null);
Assert.IsTrue(resultList.commentList.TotalCount != 0);
//test paging
_comments.ItemsPerPage = 3;
_comments.StartIndex = 5;
resultList = _comments.GetCommentForumByUid(uid, site);
Assert.IsTrue(resultList != null);
Assert.IsTrue(resultList.commentList.TotalCount != 0);
Assert.IsTrue(resultList.commentList.ItemsPerPage == _comments.ItemsPerPage);
Assert.IsTrue(resultList.commentList.StartIndex == _comments.StartIndex);
//get comment list with ascending sort
_comments.SortBy = SortBy.Created;
_comments.SortDirection = SortDirection.Ascending;
resultList = _comments.GetCommentForumByUid(uid, site);
Assert.IsTrue(resultList != null);
Assert.IsTrue(resultList.commentList.SortBy == _comments.SortBy);
Assert.IsTrue(resultList.commentList.SortDirection == _comments.SortDirection);
DateTime prevCreate = DateTime.MinValue;
DateTime currentDate = DateTime.MinValue;
for (int i = 0; i < resultList.commentList.comments.Count; i++)
{
currentDate = DateTime.Parse(resultList.commentList.comments[i].Created.At);
Assert.IsTrue(currentDate >= prevCreate);
prevCreate = currentDate;
}
//get comment list with descending sort
_comments.SortBy = SortBy.Created;
_comments.SortDirection = SortDirection.Descending;
resultList = _comments.GetCommentForumByUid(uid, site);
Assert.IsTrue(resultList != null);
Assert.IsTrue(resultList.commentList.SortBy == _comments.SortBy);
Assert.IsTrue(resultList.commentList.SortDirection == _comments.SortDirection);
prevCreate = DateTime.MaxValue;
for (int i = 0; i < resultList.commentList.comments.Count; i++)
{
currentDate = DateTime.Parse(resultList.commentList.comments[i].Created.At);
Assert.IsTrue(currentDate <= prevCreate);
prevCreate = currentDate;
}
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:84,代码来源:CommentForum.cs
示例6: CommentListReadBySiteNameAndPrefix
public void CommentListReadBySiteNameAndPrefix()
{
string prefix = "prefixtestsbycomments" + Guid.NewGuid().ToString();
CommentForum commentForum = new CommentForum
{
Id = prefix + "_" + Guid.NewGuid().ToString(),
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
//create the forum
CommentForum result = _comments.CreateCommentForum(commentForum, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
//create the comment
//set up test data
for (int i = 0; i < 10; i++)
{
CommentInfo comment = new CommentInfo
{
text = "this is a nunit generated comment."
};
comment.text += Guid.NewGuid().ToString();//have to randomize the string to post
string IPAddress = String.Empty;
Guid BBCUid = Guid.NewGuid();
//normal user
_comments.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetNormalUserAccount.UserName, _siteList);
_comments.CallingUser.CreateUserFromDnaUserID(TestUtils.TestUserAccounts.GetNormalUserAccount.UserID, site.SiteID);
CommentInfo commentInfo = _comments.CreateComment(result, comment);
Assert.IsTrue(commentInfo != null);
Assert.IsTrue(commentInfo.ID > 0);
Assert.IsTrue(commentInfo.text == comment.text);
}
//test good site
CommentsList resultList = _comments.GetCommentsListBySite(site, prefix);
Assert.IsTrue(resultList != null);
Assert.IsTrue(resultList.TotalCount == 10);
//test paging
_comments.ItemsPerPage = 3;
_comments.StartIndex = 5;
resultList = _comments.GetCommentsListBySite(site, prefix);
Assert.IsTrue(resultList != null);
Assert.IsTrue(resultList.TotalCount == 10);
Assert.IsTrue(resultList.ItemsPerPage == _comments.ItemsPerPage);
Assert.IsTrue(resultList.StartIndex == _comments.StartIndex);
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:52,代码来源:CommentForum.cs
示例7: CommentForumCreate_InReactive
public void CommentForumCreate_InReactive()
{
CommentForum commentForum = new CommentForum
{
Id = "CommentForumCreate_InReactive",
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum",
ModerationServiceGroup = ModerationStatus.ForumStatus.Reactive
};
CommentForum result = _comments.CreateCommentForum(commentForum, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
Assert.IsTrue(result.ModerationServiceGroup == ModerationStatus.ForumStatus.Reactive);
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:21,代码来源:CommentForum.cs
示例8: CommentForumCreate_MissingTitle
public void CommentForumCreate_MissingTitle()
{
CommentForum commentForum = new CommentForum
{
Id = "testCommentForum_MissingTitle",
ParentUri = "http://www.bbc.co.uk/dna/h2g2/"
};
try
{
CommentForum result = _comments.CreateCommentForum(commentForum, site);
}
catch (ApiException ex)
{
Assert.IsTrue(ex.type == ErrorType.InvalidForumTitle);
}
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:16,代码来源:CommentForum.cs
示例9: CommentForumCreate_Duplicate
public void CommentForumCreate_Duplicate()
{
CommentForum commentForum = new CommentForum
{
Id = "testCommentForum_dupe",
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
CommentForum result = _comments.CreateCommentForum(commentForum, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
//should return the same forum
result = _comments.CreateCommentForum(commentForum, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:22,代码来源:CommentForum.cs
示例10: CommentForumCreate_Good
public void CommentForumCreate_Good()
{
CommentForum commentForum = new CommentForum
{
Id = "testCommentForum_good",
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
CommentForum result = _comments.CreateCommentForum(commentForum, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:16,代码来源:CommentForum.cs
示例11: AddCommentForumToCache
/// <summary>
/// Returns the comment forum uid from cache
/// </summary>
/// <param name="site">the site of the forum</param>
/// <param name="forum">The return forum</param>
/// <returns>true if found in cache otherwise false</returns>
private void AddCommentForumToCache(CommentForum forum, ISite site)
{
string cacheKey = CommentForumCacheKey(forum.Id, site.SiteID);
//ICacheItemExpiration expiry = SlidingTime.
CacheManager.Add(cacheKey + CacheLastupdated, forum.LastUpdate, CacheItemPriority.Normal,
null, new SlidingTime(TimeSpan.FromMinutes(Cacheexpiryminutes)));
CacheManager.Add(cacheKey, forum, CacheItemPriority.Normal,
null, new SlidingTime(TimeSpan.FromMinutes(Cacheexpiryminutes)));
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:16,代码来源:Comments.cs
示例12: GetCommentForumByUidFromCache
/// <summary>
/// Returns the comment forum uid from cache
/// </summary>
/// <param name="uid">The uid of the forum</param>
/// <param name="site">the site of the forum</param>
/// <param name="forum">The return forum</param>
/// <returns>true if found in cache otherwise false</returns>
private bool GetCommentForumByUidFromCache(string uid, ISite site, ref CommentForum forum)
{
string cacheKey = CommentForumCacheKey(uid, site.SiteID);
object tempLastUpdated = CacheManager.GetData(cacheKey + CacheLastupdated);
if (tempLastUpdated == null)
{
//not found
forum = null;
Statistics.AddCacheMiss();
return false;
}
var lastUpdated = (DateTime) tempLastUpdated;
//check if cache is up to date
if (DateTime.Compare(lastUpdated, CommentForumGetLastUpdate(uid, site.SiteID)) != 0 || lastUpdated == DateTime.MinValue)
{
//cache out of date so delete
DeleteCommentForumFromCache(uid, site);
forum = null;
Statistics.AddCacheMiss();
return false;
}
//get actual cached object
forum = (CommentForum) CacheManager.GetData(cacheKey);
if (forum == null)
{
//cache out of date so delete
DeleteCommentForumFromCache(uid, site);
Statistics.AddCacheMiss();
return false;
}
//apply site variables
forum = ApplySiteVariables(forum, site);
Statistics.AddCacheHit();
//readd to cache to add sliding window affect
AddCommentForumToCache(forum, site);
return true;
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:47,代码来源:Comments.cs
示例13: CommentForumCreateFromReader
/// <summary>
/// Creates the commentforumdata from a given reader
/// </summary>
/// <param name="reader">The database reaser</param>
/// <returns>A Filled comment forum object</returns>
private CommentForum CommentForumCreateFromReader(IDnaDataReader reader)
{
var closingDate = reader.GetDateTime("forumclosedate");
//if (closingDate == null)
//{
// closingDate = DateTime.MaxValue;
//}
var site = SiteList.GetSite(reader.GetStringNullAsEmpty("sitename"));
var commentForum = new CommentForum();
commentForum.Title = reader.GetStringNullAsEmpty("Title");
commentForum.Id = reader.GetStringNullAsEmpty("UID");
commentForum.CanRead = reader.GetByteNullAsZero("canRead") == 1;
commentForum.CanWrite = reader.GetByteNullAsZero("canWrite") == 1;
commentForum.ParentUri = reader.GetStringNullAsEmpty("Url");
commentForum.SiteName = reader.GetStringNullAsEmpty("sitename");
commentForum.CloseDate = closingDate;
commentForum.LastUpdate = reader.GetDateTime("LastUpdated");
if (reader.GetDateTime("lastposted") > commentForum.LastUpdate)
{
//use last posted as it is newer
commentForum.LastUpdate = reader.GetDateTime("lastposted");
}
commentForum.Updated = new DateTimeHelper(commentForum.LastUpdate);
commentForum.Created = new DateTimeHelper(reader.GetDateTime("DateCreated"));
commentForum.commentSummary = new CommentsSummary
{
Total = reader.GetInt32NullAsZero("ForumPostCount"),
EditorPicksTotal = reader.GetInt32NullAsZero("editorpickcount")
};
commentForum.ForumID = reader.GetInt32NullAsZero("forumid");
commentForum.isClosed = !commentForum.CanWrite || site.IsEmergencyClosed ||
site.IsSiteScheduledClosed(DateTime.Now) ||
(DateTime.Now > closingDate);
//MaxCharacterCount = siteList.GetSiteOptionValueInt(site.SiteID, "CommentForum", "'MaxCommentCharacterLength")
var replacements = new Dictionary<string, string>();
replacements.Add("commentforumid", reader.GetStringNullAsEmpty("uid"));
replacements.Add("sitename", site.SiteName);
if (reader.Exists("IsContactForm") && !reader.IsDBNull("IsContactForm"))
{
commentForum.isContactForm = true;
commentForum.Uri = UriDiscoverability.GetUriWithReplacments(BasePath,
UriDiscoverability.UriType.ContactFormById,
replacements);
commentForum.commentSummary.Uri = UriDiscoverability.GetUriWithReplacments(BasePath,
UriDiscoverability.UriType.ContactFormById,
replacements);
}
else
{
commentForum.Uri = UriDiscoverability.GetUriWithReplacments(BasePath,
UriDiscoverability.UriType.CommentForumById,
replacements);
commentForum.commentSummary.Uri = UriDiscoverability.GetUriWithReplacments(BasePath,
UriDiscoverability.UriType.CommentsByCommentForumId,
replacements);
}
//get moderation status
commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.Unknown;
if (!reader.IsDBNull("moderationstatus"))
{
//if it is set for the specific forum
commentForum.ModerationServiceGroup =
(ModerationStatus.ForumStatus) (reader.GetTinyIntAsInt("moderationstatus"));
}
if (commentForum.ModerationServiceGroup == ModerationStatus.ForumStatus.Unknown)
{
//else fall back to site moderation status
switch (site.ModerationStatus)
{
case ModerationStatus.SiteStatus.UnMod:
commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.Reactive;
break;
case ModerationStatus.SiteStatus.PreMod:
commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.PreMod;
break;
case ModerationStatus.SiteStatus.PostMod:
commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.PostMod;
break;
default:
commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.Reactive;
break;
}
}
commentForum.NotSignedInUserId = reader.GetInt32NullAsZero("NotSignedInUserId");
commentForum.allowNotSignedInCommenting = commentForum.NotSignedInUserId != 0;
return commentForum;
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:98,代码来源:Comments.cs
示例14: CheckCommentIsOrIsNotInTheCommentList
public static void CheckCommentIsOrIsNotInTheCommentList(DnaTestURLRequest request, bool isInList, string textToCheck, CommentForum commentForum)
{
CallGETCommentForumAPIRequest(request, "h2g2", commentForum.Id);
var currentCommentForum = (CommentForum)request.GetLastResponseAsJSONObject(typeof(CommentForum));
bool match = false;
Console.WriteLine("Text just posted : " + textToCheck);
foreach (CommentInfo comment in currentCommentForum.commentList.comments)
{
match |= textToCheck.CompareTo(comment.text) == 0;
Console.WriteLine("Comment in list : " + comment.text);
}
Console.WriteLine("Post found in comment list : " + match);
if (isInList)
{
Assert.IsTrue(match);
}
else
{
Assert.IsFalse(match);
}
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:23,代码来源:CommentForumTestUtils.cs
示例15: HandleRetweet
/// <summary>
/// Method that choses the way the retweet needs to be handled
/// </summary>
/// <param name="site"></param>
/// <param name="commentForumData"></param>
/// <param name="tweet"></param>
/// <param name="commentObj"></param>
/// <returns></returns>
private Stream HandleRetweet(ISite site, CommentForum commentForumData, Tweet tweet)
{
if (false == string.IsNullOrEmpty(tweet.Text))
{
var callingOriginalTweetuser = GetCallingTwitterUser(site, tweet.RetweetedStatus);
if (callingOriginalTweetuser.IsTrustedUser())
{
return HandleRetweetOriginalTweetByTrustedUsers(site, commentForumData, tweet);
}
else
{
return HandleRetweetOriginalTweetByPublicUsers(site, commentForumData, tweet);
}
}
else
{
throw ApiException.GetError(ErrorType.EmptyText);
}
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:28,代码来源:TwitterService.cs
示例16: CommentForumReadByUID
public void CommentForumReadByUID()
{
CommentForum commentForum = new CommentForum
{
Id = "testCommentForum_readUID",
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
//create the forum
CommentForum result = _comments.CreateCommentForum(commentForum, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
//create the comment
//set up test data
CommentInfo comment = new CommentInfo
{
text = "this is a nunit generated comment."
};
comment.text += Guid.NewGuid().ToString();//have to randomize the string to post
string IPAddress = String.Empty;
Guid BBCUid = Guid.NewGuid();
//normal user
_comments.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetNormalUserAccount.UserName, _siteList);
_comments.CallingUser.CreateUserFromDnaUserID(TestUtils.TestUserAccounts.GetNormalUserAccount.UserID, site.SiteID);
CommentInfo commentInfo = _comments.CreateComment(result, comment);
Assert.IsTrue(commentInfo != null);
Assert.IsTrue(commentInfo.ID > 0);
Assert.IsTrue(commentInfo.text == comment.text);
string badUid = "not a UID";
//test good site
result = _comments.GetCommentForumByUid(commentForum.Id, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.commentList != null);
Assert.IsTrue(result.commentList.TotalCount != 0);
//test paging
_comments.ItemsPerPage = 50;
_comments.StartIndex = 0;
result = _comments.GetCommentForumByUid(commentForum.Id, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.commentList != null);
Assert.IsTrue(result.commentList.TotalCount != 0);
Assert.IsTrue(result.commentList.ItemsPerPage == _comments.ItemsPerPage);
Assert.IsTrue(result.commentList.StartIndex == _comments.StartIndex);
//test bad site name
result = _comments.GetCommentForumByUid(badUid, site);
Assert.IsTrue(result == null);
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:56,代码来源:CommentForum.cs
示例17: CommentsReadByForumID
public void CommentsReadByForumID()
{
CommentForum commentForum = new CommentForum
{
Id = "testCommentForum_good" + Guid.NewGuid().ToString(),
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
CommentForum resultCommentForum = _comments.CreateCommentForum(commentForum, site);
Assert.IsTrue(resultCommentForum != null);
Assert.IsTrue(resultCommentForum.Id == commentForum.Id);
Assert.IsTrue(resultCommentForum.ParentUri == commentForum.ParentUri);
Assert.IsTrue(resultCommentForum.Title == commentForum.Title);
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:15,代码来源:CommentForum.cs
示例18: ApplySiteVariables
/// <summary>
/// applies the site specific items
/// </summary>
/// <param name="forum"></param>
/// <param name="site"></param>
/// <returns></returns>
private static CommentForum ApplySiteVariables(CommentForum forum, ISite site)
{
forum.isClosed = forum.isClosed || site.IsEmergencyClosed || site.IsSiteScheduledClosed(DateTime.Now) ||
(DateTime.Now > forum.CloseDate);
return forum;
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:12,代码来源:Comments.cs
示例19: CommentForumCreate_WithTooManyUIDChars
public void CommentForumCreate_WithTooManyUIDChars()
{
//create namespace and ID which equal 255
CommentForum commentForum = new CommentForum
{
Id = "".PadRight(256, 'I'),
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
try
{
//should throw error stating uid length too long
CommentForum result = _comments.CreateCommentForum(commentForum, site);
}
catch (ApiException ex)
{
Assert.IsTrue(ex.type == ErrorType.InvalidForumUid);
}
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:21,代码来源:CommentForum.cs
示例20: GetCommentForumByUids
/// <summary>
/// Comment forum that reads comments from multiple forums
/// </summary>
/// <param name="uidList">List of form uid</param>
/// <param name="site"></param>
/// <returns>Comment forum object including comments from all the forums</returns>
public CommentForum GetCommentForumByUids(string uidList, ISite site)
{
CommentForum commentForum = null;
if (GetCommentForumByUidFromCache(uidList, site, ref commentForum))
{
return commentForum;
}
try
{
commentForum = new CommentForum();
commentForum.commentSummary = new CommentsSummary();
commentForum.Id = uidList;
commentForum.commentList = GetCommentsListByForumIds(uidList, site);
commentForum.identityPolicy = site.IdentityPolicy;
AddCommentForumToCache(commentForum, site);
}
catch (Exception ex)
{
throw new ApiException(ex.Message, ex.InnerException);
//DnaApiWebProtocalException.ThrowDnaApiWebProtocalException(System.Net.HttpStatusCode.InternalServerError, ex.Message, ex);
}
return commentForum;
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:32,代码来源:Comments.cs
注:本文中的BBC.Dna.Api.CommentForum类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论