本文整理汇总了C#中Comments.CreateCommentRating方法的典型用法代码示例。如果您正苦于以下问题:C# Comments.CreateCommentRating方法的具体用法?C# Comments.CreateCommentRating怎么用?C# Comments.CreateCommentRating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments.CreateCommentRating方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCommentRating_AsUser_ReturnsValue
public void CreateCommentRating_AsUser_ReturnsValue()
{
var value = 1;
var posvalue = 20;
var negvalue = -10;
var postId = 1;
var userid = 1;
var commentForum = new CommentForum() { ForumID = 1 };
ISite site = mocks.DynamicMock<ISite>();
site.Stub(x => x.SiteID).Return(1);
var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
var reader = mocks.DynamicMock<IDnaDataReader>();
reader.Stub(x => x.Read()).Return(true);
reader.Stub(x => x.HasRows).Return(true);
reader.Stub(x => x.GetInt32NullAsZero("nerovalue")).Return(value);
reader.Stub(x => x.GetInt32NullAsZero("neropositivevalue")).Return(posvalue);
reader.Stub(x => x.GetInt32NullAsZero("neronegativevalue")).Return(negvalue);
readerCreator.Stub(x => x.CreateDnaDataReader("commentratingcreate")).Return(reader);
mocks.ReplayAll();
var comments = new Comments(null, readerCreator, null, null)
{
IpAddress = "1.1.1.1",
BbcUid = Guid.NewGuid()
};
var retVal = comments.CreateCommentRating(commentForum, site, postId, userid, (short)value);
Assert.AreEqual(value, retVal.neroValue);
Assert.AreEqual(posvalue, retVal.positiveNeroValue);
Assert.AreEqual(negvalue, retVal.negativeNeroValue);
reader.AssertWasCalled(x => x.Execute());
}
示例2: CreateCommentRating_DBThrowsException_ThrowsError
public void CreateCommentRating_DBThrowsException_ThrowsError()
{
var value = 1;
var postId = 1;
var userid = 0;
var commentForum = new CommentForum() { ForumID = 1 };
ISite site = null;
var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
var reader = mocks.DynamicMock<IDnaDataReader>();
reader.Stub(x => x.Read()).Return(true);
reader.Stub(x => x.HasRows).Return(true);
reader.Stub(x => x.GetInt32NullAsZero("value")).Return(value);
readerCreator.Stub(x => x.CreateDnaDataReader("commentratingcreate")).Return(reader);
reader.Stub(x => x.Execute()).Throw(new Exception("test"));
mocks.ReplayAll();
var comments = new Comments(null, readerCreator, null, null)
{
IpAddress = "1.1.1.1",
BbcUid = Guid.NewGuid()
};
try
{
comments.CreateCommentRating(commentForum, site, postId, userid, (short)value);
}
catch (ApiException ex)
{
Assert.AreEqual(ErrorType.Unknown, ex.type);
}
//reader.AssertWasNotCalled(x => x.Execute());
}
示例3: CreateCommentRating_AsAnonymousWithoutDetails_ThrowsError
public void CreateCommentRating_AsAnonymousWithoutDetails_ThrowsError()
{
var value = 1;
var postId = 1;
var userid = 0;
var commentForum = new CommentForum() { ForumID=1 };
ISite site = null;
var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
var reader = mocks.DynamicMock<IDnaDataReader>();
reader.Stub(x => x.Read()).Return(true);
reader.Stub(x => x.HasRows).Return(true);
reader.Stub(x => x.GetInt32NullAsZero("value")).Return(value);
readerCreator.Stub(x => x.CreateDnaDataReader("commentratingcreate")).Return(reader);
mocks.ReplayAll();
var comments = new Comments(null, readerCreator, null, null)
{
};
try
{
comments.CreateCommentRating(commentForum, site, postId, userid, (short)value);
}
catch (ApiException ex)
{
Assert.AreEqual(ErrorType.MissingUserAttributes, ex.type);
}
reader.AssertWasNotCalled(x => x.Execute());
}