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


C# Comments.GetCommentsListBySite方法代码示例

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


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

示例1: CommentsReadBySite_ValidCache_ReturnsValidList

        public void CommentsReadBySite_ValidCache_ReturnsValidList()
        {
            var lastUpdate = DateTime.Now.AddDays(1);
            var comments = new Comments(null, null, null, null);
            var validCommentsList = new CommentsList {comments = new List<CommentInfo>()};
            var siteList = mocks.DynamicMock<ISiteList>();
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var site = mocks.DynamicMock<ISite>();
            var readerComments = mocks.DynamicMock<IDnaDataReader>();
            var readerLastUpdate = mocks.DynamicMock<IDnaDataReader>();

            var cacheManager = mocks.DynamicMock<ICacheManager>();
            var siteName = "h2g2";
            string cacheKey = comments.CommentListCacheKey(0, "");

            cacheManager.Stub(x => x.GetData(cacheKey)).Return(validCommentsList);
            cacheManager.Stub(x => x.GetData(cacheKey + "|LASTUPDATED")).Return(lastUpdate);
            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);

            readerComments.Stub(x => x.HasRows).Return(true);
            readerComments.Stub(x => x.Read()).Return(true).Repeat.Once();
            readerComments.Stub(x => x.GetInt32NullAsZero("totalresults")).Return(1);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentsreadbysitename")).Return(readerComments);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentsgetlastupdatebysite")).Return(readerLastUpdate);

            readerLastUpdate.Stub(x => x.HasRows).Return(true);
            readerLastUpdate.Stub(x => x.Read()).Return(true).Repeat.Once();
            readerLastUpdate.Stub(x => x.GetDateTime("lastupdated")).Return(lastUpdate);

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

            comments = new Comments(null, readerCreator, cacheManager, siteList);
            var commentList = comments.GetCommentsListBySite(site);

            Assert.IsNotNull(commentList);
            readerCreator.AssertWasNotCalled(x => x.CreateDnaDataReader("commentsreadbysitename"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:40,代码来源:CommentsTest.cs

示例2: CommentsReadBySite_WithPrefixFromDbCorrectInput_ReturnsValidList

        public void CommentsReadBySite_WithPrefixFromDbCorrectInput_ReturnsValidList()
        {

            var siteList = mocks.DynamicMock<ISiteList>();
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var site = mocks.DynamicMock<ISite>();
            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);

            readerComments.Stub(x => x.HasRows).Return(true);
            readerComments.Stub(x => x.Read()).Return(true).Repeat.Once();
            readerComments.Stub(x => x.GetInt32NullAsZero("totalresults")).Return(1);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentsreadbysitenameprefix")).Return(readerComments);

            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 commentList = comments.GetCommentsListBySite(site, "prefix");

            Assert.IsNotNull(commentList);
            Assert.AreEqual(1, commentList.TotalCount);
            Assert.AreEqual(1, commentList.comments.Count);
            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentsreadbysitenameprefix"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:34,代码来源:CommentsTest.cs

示例3: CommentsReadBySite_CacheInDateMissingActualObject_ReturnsValidList

        public void CommentsReadBySite_CacheInDateMissingActualObject_ReturnsValidList()
        {
            var lastUpdate = DateTime.Now.AddDays(1);
            var comments = new Comments(null, null, null, null);

            var siteList = mocks.DynamicMock<ISiteList>();
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var site = mocks.DynamicMock<ISite>();
            var readerComments = mocks.DynamicMock<IDnaDataReader>();
            var readerLastUpdate = mocks.DynamicMock<IDnaDataReader>();

            var cacheManager = mocks.DynamicMock<ICacheManager>();
            var siteName = "h2g2";
            string cacheKey = comments.CommentListCacheKey(0, "");

            cacheManager.Stub(x => x.GetData(cacheKey)).Return(null);
            cacheManager.Stub(x => x.GetData(cacheKey + "|LASTUPDATED")).Return(lastUpdate);
            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);

            readerComments.Stub(x => x.HasRows).Return(true);
            readerComments.Stub(x => x.Read()).Return(true).Repeat.Once();
            readerComments.Stub(x => x.GetInt32NullAsZero("totalresults")).Return(1);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentsreadbysitename")).Return(readerComments);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentsgetlastupdatebysite")).Return(readerLastUpdate);

            readerLastUpdate.Stub(x => x.HasRows).Return(true);
            readerLastUpdate.Stub(x => x.Read()).Return(true).Repeat.Once();
            readerLastUpdate.Stub(x => x.GetDateTime("lastupdated")).Return(lastUpdate);

            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();

            comments = new Comments(null, readerCreator, cacheManager, siteList);
            var commentList = comments.GetCommentsListBySite(site);

            Assert.IsNotNull(commentList);
            Assert.AreEqual(1, commentList.TotalCount);
            Assert.AreEqual(1, commentList.comments.Count);
            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentsreadbysitename"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:44,代码来源:CommentsTest.cs

示例4: CommentsReadBySite_FromDbCorrectInputEditorsPicks_ReturnsValidList

        public void CommentsReadBySite_FromDbCorrectInputEditorsPicks_ReturnsValidList()
        {

            var siteList = mocks.DynamicMock<ISiteList>();
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var site = mocks.DynamicMock<ISite>();
            var readerComments = mocks.DynamicMock<IDnaDataReader>();

            var cacheManager = mocks.DynamicMock<ICacheManager>();
            var siteName = "h2g2";
            var siteId = 1;
            var userName = "myudng";

            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);
            site.Stub(x => x.SiteID).Return(siteId);

            readerComments.Stub(x => x.HasRows).Return(true);
            readerComments.Stub(x => x.Read()).Return(true).Repeat.Once();
            readerComments.Stub(x => x.DoesFieldExist("SiteSpecificDisplayName")).Return(true);
            readerComments.Stub(x => x.GetStringNullAsEmpty("SiteSpecificDisplayName")).Return(userName);
            readerComments.Stub(x => x.GetInt32NullAsZero("totalresults")).Return(1);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentsreadbysitenameeditorpicksfilter")).Return(readerComments);

            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);
            siteList.Stub(x => x.GetSiteOptionValueBool(siteId, "User", "UseSiteSuffix")).Return(true);
            mocks.ReplayAll();

            var comments = new Comments(null, readerCreator, cacheManager, siteList);
            comments.FilterBy = FilterBy.EditorPicks;
            var commentList = comments.GetCommentsListBySite(site);

            Assert.IsNotNull(commentList);
            Assert.AreEqual(1, commentList.TotalCount);
            Assert.AreEqual(1, commentList.comments.Count);
            Assert.AreEqual(userName, commentList.comments[0].User.SiteSpecificDisplayName);
            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentsreadbysitenameeditorpicksfilter"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:42,代码来源:CommentsTest.cs


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