当前位置: 首页>>代码示例>>C#>>正文


C# Comments.CreateCommentRating方法代码示例

本文整理汇总了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());
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:35,代码来源:CommentsTest.cs

示例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());
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:36,代码来源:CommentsTest.cs

示例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());
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:33,代码来源:CommentsTest.cs


注:本文中的Comments.CreateCommentRating方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。