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


C# Comments.CreateAndUpdateCommentForum方法代码示例

本文整理汇总了C#中Comments.CreateAndUpdateCommentForum方法的典型用法代码示例。如果您正苦于以下问题:C# Comments.CreateAndUpdateCommentForum方法的具体用法?C# Comments.CreateAndUpdateCommentForum怎么用?C# Comments.CreateAndUpdateCommentForum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comments的用法示例。


在下文中一共展示了Comments.CreateAndUpdateCommentForum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAndUpdateCommentForum_NoExists_CreatesForum

        public void CreateAndUpdateCommentForum_NoExists_CreatesForum()
        {
            var siteList = mocks.DynamicMock<ISiteList>();
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var site = mocks.DynamicMock<ISite>();
            var reader = mocks.DynamicMock<IDnaDataReader>();
            var readerCreate = mocks.DynamicMock<IDnaDataReader>();
            var readerComments = mocks.DynamicMock<IDnaDataReader>();

            var cacheManager = mocks.DynamicMock<ICacheManager>();
            var siteName = "h2g2";

            cacheManager.Stub(x => x.GetData("")).Return(null).Constraints(Is.Anything());
            site.Stub(x => x.ModerationStatus).Return(ModerationStatus.SiteStatus.UnMod);
            site.Stub(x => x.IsEmergencyClosed).Return(false);
            site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Return(false);

            reader.Stub(x => x.HasRows).Return(false);
            reader.Stub(x => x.Read()).Return(false);
            readerComments.Stub(x => x.HasRows).Return(false);
            readerComments.Stub(x => x.Read()).Return(false);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentforumreadbyuid")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentsreadbyforumid")).Return(readerComments);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentforumcreate")).Return(readerCreate);

            siteList.Stub(x => x.GetSite(siteName)).Return(site);

            var commentForum = new Forum
            {
                Id = "".PadRight(10, 'a'),
                ParentUri = "http://www.bbc.co.uk/dna",
                Title = "title",
                ModerationServiceGroup = ModerationStatus.ForumStatus.PostMod
            };


            mocks.ReplayAll();

            var comments = new Comments(null, readerCreator, cacheManager, siteList);
            var forum = comments.CreateAndUpdateCommentForum(commentForum, site, null);
            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentforumreadbyuid"));
            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentforumcreate"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:43,代码来源:CommentsTest.cs

示例2: CreateAndUpdateCommentForum_AlreadyExists_ThenUpdate

        public void CreateAndUpdateCommentForum_AlreadyExists_ThenUpdate()
        {
            var siteList = mocks.DynamicMock<ISiteList>();
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var site = mocks.DynamicMock<ISite>();
            var reader = mocks.DynamicMock<IDnaDataReader>();
            var readerComments = mocks.DynamicMock<IDnaDataReader>();
            var readerUpdate = mocks.DynamicMock<IDnaDataReader>();

            var cacheManager = mocks.DynamicMock<ICacheManager>();
            var siteName = "h2g2";
            var uid = "uid";
            var commentForum = new CommentForum
            {
                Id = uid,
                Title = "title",
                ParentUri = "https://www.bbc.co.uk"

            };

            cacheManager.Stub(x => x.GetData("")).Return(null).Constraints(Is.Anything());
            site.Stub(x => x.ModerationStatus).Return(ModerationStatus.SiteStatus.UnMod);
            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.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("sitename")).Return(siteName);
            reader.Stub(x => x.GetStringNullAsEmpty("UID")).Return(uid);
            reader.Stub(x => x.GetStringNullAsEmpty("Title")).Return(uid);
            reader.Stub(x => x.GetStringNullAsEmpty("Url")).Return("https://www.bbc.co.uk");
            

            readerUpdate.Stub(x => x.HasRows).Return(true);
            readerUpdate.Stub(x => x.Read()).Return(true).Repeat.Once();
            readerUpdate.Stub(x => x.GetStringNullAsEmpty("sitename")).Return(siteName);


            readerComments.Stub(x => x.HasRows).Return(true);
            readerComments.Stub(x => x.Read()).Return(true).Repeat.Twice();
            readerComments.Stub(x => x.GetInt32NullAsZero("totalresults")).Return(1);

            readerCreator.Stub(x => x.CreateDnaDataReader("commentforumreadbyuid")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentsreadbyforumid")).Return(readerComments);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentforumupdate")).Return(readerUpdate);
            

            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);
            var forum = comments.CreateAndUpdateCommentForum(commentForum, site, null);

            Assert.IsNotNull(forum);
            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentforumreadbyuid"));
            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentforumupdate"));
            readerCreator.AssertWasNotCalled(x => x.CreateDnaDataReader("commentforumcreate"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:60,代码来源:CommentsTest.cs


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