本文整理汇总了C#中Comments.CreateComment方法的典型用法代码示例。如果您正苦于以下问题:C# Comments.CreateComment方法的具体用法?C# Comments.CreateComment怎么用?C# Comments.CreateComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments.CreateComment方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addcomment
protected void addcomment(object sender, ImageClickEventArgs e)
{
Security.UserInfo usr = new Security.UserInfo();
string username = Session["USERNAME"].ToString();
Security.UserInfo usrs = usr.getUserProfileFromEmail(username);
Comments com = new Comments();
string brandid = Request.QueryString["id"];
com.BrandID =""+ brandid+"";
com.Comment = txtdiscption.InnerText;
com.UserID = usrs.UserID;
com.Deleted = false;
com.Date = System.DateTime.Now;
com.PostAsAnonymous = false;
com.BrandCommentID = 0;
com.CreateComment(com);
}
示例2: CommentCreate_BannedUser_ReturnCorrectError
public void CommentCreate_BannedUser_ReturnCorrectError()
{
var siteName = "h2g2";
var uid = "uid";
var siteList = mocks.DynamicMock<ISiteList>();
var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
var site = mocks.DynamicMock<ISite>();
var reader = mocks.DynamicMock<IDnaDataReader>();
var cacheManager = mocks.DynamicMock<ICacheManager>();
var callingUser = mocks.DynamicMock<ICallingUser>();
var commentForum = new CommentForum { Id = uid, SiteName = siteName };
var commentInfo = new CommentInfo { text = "test" };
callingUser.Stub(x => x.IsSecureRequest).Return(true);
callingUser.Stub(x => x.UserID).Return(1);
callingUser.Stub(x => x.IsUserA(UserTypes.BannedUser)).Return(true);
cacheManager.Stub(x => x.GetData("")).Return(null).Constraints(Is.Anything());
site.Stub(x => x.IsEmergencyClosed).Return(false);
site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Return(false);
reader.Stub(x => x.HasRows).Return(true);
reader.Stub(x => x.Read()).Return(true).Repeat.Once();
readerCreator.Stub(x => x.CreateDnaDataReader("commentcreate")).Return(reader);
siteList.Stub(x => x.GetSite(siteName)).Return(site);
mocks.ReplayAll();
var comments = new Comments(null, readerCreator, cacheManager, siteList);
comments.CallingUser = callingUser;
try
{
comments.CreateComment(commentForum, commentInfo);
throw new Exception("No exception thrown");
}
catch (ApiException ex)
{
Assert.AreEqual(ErrorType.UserIsBanned, ex.type);
}
readerCreator.AssertWasNotCalled(x => x.CreateDnaDataReader("commentcreate"));
}
示例3: CommentCreate_AsPreMod_ReturnCorrectError
public void CommentCreate_AsPreMod_ReturnCorrectError()
{
var siteName = "h2g2";
var siteId = 1;
var uid = "uid";
var text = "test text";
var siteList = mocks.DynamicMock<ISiteList>();
var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
var site = mocks.DynamicMock<ISite>();
var reader = mocks.DynamicMock<IDnaDataReader>();
var cacheManager = mocks.DynamicMock<ICacheManager>();
var callingUser = mocks.DynamicMock<ICallingUser>();
var commentForum = new CommentForum { Id = uid, SiteName = siteName, ModerationServiceGroup = ModerationStatus.ForumStatus.PreMod };
var commentInfo = new CommentInfo { text = text };
callingUser.Stub(x => x.IsSecureRequest).Return(true);
callingUser.Stub(x => x.UserID).Return(1);
callingUser.Stub(x => x.IsUserA(UserTypes.SuperUser)).Return(false).Constraints(Is.Anything());
cacheManager.Stub(x => x.GetData("")).Return(null).Constraints(Is.Anything());
site.Stub(x => x.SiteID).Return(siteId);
site.Stub(x => x.IsEmergencyClosed).Return(false);
site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Return(false);
reader.Stub(x => x.HasRows).Return(true);
reader.Stub(x => x.Read()).Return(true).Repeat.Once();
readerCreator.Stub(x => x.CreateDnaDataReader("commentcreate")).Return(reader);
siteList.Stub(x => x.GetSite(siteName)).Return(site);
mocks.ReplayAll();
var comments = new Comments(null, readerCreator, cacheManager, siteList);
comments.CallingUser = callingUser;
var comment = comments.CreateComment(commentForum, commentInfo);
Assert.IsNotNull(comment);
readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentcreate"));
}
示例4: CommentCreate_NotSignedInUserWithDisplayName_ReturnCorrectObject
public void CommentCreate_NotSignedInUserWithDisplayName_ReturnCorrectObject()
{
var siteName = "h2g2";
var uid = "uid";
var text = "test comment";
var displayName = "notsignedin";
var siteList = mocks.DynamicMock<ISiteList>();
var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
var site = mocks.DynamicMock<ISite>();
var reader = mocks.DynamicMock<IDnaDataReader>();
var cacheManager = mocks.DynamicMock<ICacheManager>();
var callingUser = mocks.DynamicMock<ICallingUser>();
var commentForum = new CommentForum { Id = uid, SiteName = siteName, allowNotSignedInCommenting=true, NotSignedInUserId=1 };
var commentInfo = new CommentInfo { text = text };
commentInfo.User = new User { DisplayName = displayName };
callingUser.Stub(x => x.IsSecureRequest).Return(true);
callingUser.Stub(x => x.UserID).Return(1);
callingUser.Stub(x => x.IsUserA(UserTypes.SuperUser)).Return(false).Constraints(Is.Anything());
cacheManager.Stub(x => x.GetData("")).Return(null).Constraints(Is.Anything());
site.Stub(x => x.IsEmergencyClosed).Return(false);
site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Return(false);
reader.Stub(x => x.HasRows).Return(true);
reader.Stub(x => x.Read()).Return(true).Repeat.Once();
reader.Stub(x => x.GetInt32NullAsZero("postid")).Return(1);
readerCreator.Stub(x => x.CreateDnaDataReader("commentcreate")).Return(reader);
site.Stub(x => x.SiteID).Return(1);
siteList.Stub(x => x.GetSiteOptionValueString(1, "General", "ComplaintUrl")).Return("http://www.bbc.co.uk/dna/[sitename]/comments/UserComplaintPage?PostID=[postid]&s_start=1");
siteList.Stub(x => x.GetSite(siteName)).Return(site);
mocks.ReplayAll();
var comments = new Comments(null, readerCreator, cacheManager, siteList);
comments.CallingUser = callingUser;
var comment = comments.CreateComment(commentForum, commentInfo);
Assert.IsNotNull(comment);
Assert.AreEqual(displayName, comment.User.DisplayName);
readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentcreate"));
reader.AssertWasCalled(x => x.AddParameter("nickname", displayName));
}
示例5: CommentCreate_ForumClosed_NotableUser_ReturnResults
public void CommentCreate_ForumClosed_NotableUser_ReturnResults()
{
var siteName = "h2g2";
var siteId = 1;
var uid = "uid";
var text = "test comment";
var siteList = mocks.DynamicMock<ISiteList>();
var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
var site = mocks.DynamicMock<ISite>();
var reader = mocks.DynamicMock<IDnaDataReader>();
var cacheManager = mocks.DynamicMock<ICacheManager>();
var callingUser = mocks.DynamicMock<ICallingUser>();
var commentForum = new CommentForum { Id = uid, SiteName = siteName };
var commentInfo = new CommentInfo { text = text };
callingUser.Stub(x => x.IsSecureRequest).Return(true);
callingUser.Stub(x => x.UserID).Return(1);
callingUser.Stub(x => x.IsUserA(UserTypes.Notable)).Return(true);
cacheManager.Stub(x => x.GetData("")).Return(null).Constraints(Is.Anything());
site.Stub(x => x.SiteID).Return(siteId);
site.Stub(x => x.IsEmergencyClosed).Return(false);
site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Return(false);
reader.Stub(x => x.HasRows).Return(true);
reader.Stub(x => x.Read()).Return(true).Repeat.Once();
readerCreator.Stub(x => x.CreateDnaDataReader("commentcreate")).Return(reader);
siteList.Stub(x => x.GetSite(siteName)).Return(site);
mocks.ReplayAll();
var comments = new Comments(null, readerCreator, cacheManager, siteList);
comments.CallingUser = callingUser;
var retVal = comments.CreateComment(commentForum, commentInfo);
Assert.AreEqual(text, retVal.text);
reader.AssertWasCalled(x => x.Execute());
}
示例6: CommentCreate_WithWhiteListTerm_AddsCorrectNotes
public void CommentCreate_WithWhiteListTerm_AddsCorrectNotes()
{
var siteName = "h2g2";
var siteId = 1;
var uid = "uid";
var text = " Bomb ";
var siteList = mocks.DynamicMock<ISiteList>();
var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
var site = mocks.DynamicMock<ISite>();
var reader = mocks.DynamicMock<IDnaDataReader>();
var cacheManager = mocks.DynamicMock<ICacheManager>();
var callingUser = mocks.DynamicMock<ICallingUser>();
var commentForum = new CommentForum { Id = uid, SiteName = siteName };
var commentInfo = new CommentInfo { text = text };
callingUser.Stub(x => x.IsSecureRequest).Return(true);
callingUser.Stub(x => x.UserID).Return(1);
callingUser.Stub(x => x.IsUserA(UserTypes.SuperUser)).Return(false).Constraints(Is.Anything());
cacheManager.Stub(x => x.GetData("")).Return(null).Constraints(Is.Anything());
site.Stub(x => x.SiteID).Return(siteId);
site.Stub(x => x.IsEmergencyClosed).Return(false);
site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Return(false);
site.Stub(x => x.ModClassID).Return(3);
reader.Stub(x => x.HasRows).Return(true);
reader.Stub(x => x.Read()).Return(true).Repeat.Once();
readerCreator.Stub(x => x.CreateDnaDataReader("commentcreate")).Return(reader);
siteList.Stub(x => x.GetSite(siteName)).Return(site);
mocks.ReplayAll();
var comments = new Comments(null, readerCreator, cacheManager, siteList);
comments.CallingUser = callingUser;
comments.CreateComment(commentForum, commentInfo);
readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentcreate"));
reader.AssertWasCalled(x => x.AddParameter("modnotes", "Filtered terms: bomb"));
}
示例7: CommentCreate_NotSecureWithoutSiteOption_ReturnCorrectComment
public void CommentCreate_NotSecureWithoutSiteOption_ReturnCorrectComment()
{
var siteName = "h2g2";
var uid = "uid";
var text = "Here is my text that is not posted securely";
var siteList = mocks.DynamicMock<ISiteList>();
var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
var site = mocks.DynamicMock<ISite>();
var reader = mocks.DynamicMock<IDnaDataReader>();
var cacheManager = mocks.DynamicMock<ICacheManager>();
var callingUser = mocks.DynamicMock<ICallingUser>();
var commentForum = new CommentForum { Id = uid, SiteName = siteName };
var commentInfo = new CommentInfo { text = text };
callingUser.Stub(x => x.UserID).Return(1);
callingUser.Stub(x => x.IsUserA(UserTypes.SuperUser)).Return(false).Constraints(Is.Anything());
cacheManager.Stub(x => x.GetData("")).Return(null).Constraints(Is.Anything());
site.Stub(x => x.IsEmergencyClosed).Return(false);
site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Return(false);
reader.Stub(x => x.HasRows).Return(true);
reader.Stub(x => x.Read()).Return(true).Repeat.Once();
readerCreator.Stub(x => x.CreateDnaDataReader("commentcreate")).Return(reader);
siteList.Stub(x => x.GetSite(siteName)).Return(site);
siteList.Stub(x => x.GetSiteOptionValueInt(0, "CommentForum", "EnforceSecurePosting")).Return(0);
mocks.ReplayAll();
var comments = new Comments(null, readerCreator, cacheManager, siteList);
comments.CallingUser = callingUser;
comments.CreateComment(commentForum, commentInfo);
readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentcreate"));
}