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


C# Comments.GetCommentForumsActivity方法代码示例

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


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

示例1: ValidParamsCalledTwiceWithin1Minute_UsesCachedVersionOnSecondCall

        public void ValidParamsCalledTwiceWithin1Minute_UsesCachedVersionOnSecondCall()
        {
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var reader = mocks.DynamicMock<IDnaDataReader>();
            var cacheManager = mocks.DynamicMock<ICacheManager>();

            DateTime startSampleTime = DateTime.Now.AddMinutes(-1);
            int minutes = 1; // URL Default
            
            int totalActiveForums = 1;
            DateTime closeDate = DateTime.Now.AddDays(1.0);
            int count = 5;
            DateTime lastPostedDate = DateTime.Now.AddMinutes(-0.5);
            int siteId = 1;
            string urlName = "h2g2";
            string title = "Test Title";
            int totalPosts = 20;
            string url = "https://local.bbc.co.uk/dna/h2g2/comments";

            StubDatabaseCall(readerCreator, reader, totalActiveForums, closeDate, count, lastPostedDate, siteId, urlName, title, totalPosts, url);

            CommentForumActivity cachedActivity = new CommentForumActivity();
            cachedActivity.ClosingDate = new DateTimeHelper(closeDate);
            cachedActivity.Count = count;
            cachedActivity.LastPostedDate = new DateTimeHelper(lastPostedDate);
            cachedActivity.SiteId = siteId;
            cachedActivity.SiteName = urlName;
            cachedActivity.Title = title;
            cachedActivity.TotalPosts = totalPosts;
            cachedActivity.URL = url;
            CommentForumsActivityList cachedActivityList = new CommentForumsActivityList();
            cachedActivityList.CommentForumsActivity = new List<CommentForumActivity>();
            cachedActivityList.CommentForumsActivity.Add(cachedActivity);
            cachedActivityList.DateChecked = new DateTimeHelper(DateTime.Now);
            cachedActivityList.Minutes = minutes;
            cachedActivityList.StartDate = new DateTimeHelper(startSampleTime);

            cacheManager.Stub(x => x.GetData(Arg<string>.Is.Anything)).Return(null).Repeat.Once(); // Not cached first time
            cacheManager.Stub(x => x.GetData(Arg<string>.Is.Anything)).Return(cachedActivityList).Repeat.Once(); // Cached second time

            mocks.ReplayAll();

            Comments comments = new Comments(null, readerCreator, cacheManager, null);
            CommentForumsActivityList activity = comments.GetCommentForumsActivity(minutes, startSampleTime.ToString());

            VerifyActivityList(totalActiveForums, minutes, closeDate, startSampleTime, count, lastPostedDate, siteId, urlName, title, totalPosts, url, activity);

            activity = comments.GetCommentForumsActivity(minutes, startSampleTime.ToString());

            VerifyActivityList(totalActiveForums, minutes, closeDate, startSampleTime, count, lastPostedDate, siteId, urlName, title, totalPosts, url, activity);

            cacheManager.AssertWasCalled(x => x.GetData(Arg<string>.Is.Anything), options => options.Repeat.Times(2));
            cacheManager.AssertWasCalled(x => x.Add(Arg<string>.Is.Anything, Arg<object>.Is.Anything, Arg<CacheItemPriority>.Is.Anything, Arg<ICacheItemRefreshAction>.Is.Anything, Arg<ICacheItemExpiration>.Is.Anything), options => options.Repeat.Once());
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:54,代码来源:CommentForumActivityTests.cs

示例2: DefaultURLParams_ReturnsActivityForOneMinute

        public void DefaultURLParams_ReturnsActivityForOneMinute()
        {
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var reader = mocks.DynamicMock<IDnaDataReader>();
            var cacheManager = mocks.DynamicMock<ICacheManager>();

            DateTime startSampleTime = DateTime.Now.AddMinutes(-1); // URL Default is 1 minute
            int minutes = 1; // URL Default

            int totalActiveForums = 1;
            DateTime closeDate = DateTime.Now.AddDays(1.0);
            int count = 5;
            DateTime lastPostedDate = DateTime.Now.AddMinutes(-0.5);
            int siteId = 1;
            string urlName = "h2g2";
            string title = "Test Title";
            int totalPosts = 20;
            string url = "https://local.bbc.co.uk/dna/h2g2/comments";

            StubDatabaseCall(readerCreator, reader, totalActiveForums, closeDate, count, lastPostedDate, siteId, urlName, title, totalPosts, url);

            mocks.ReplayAll();

            Comments comments = new Comments(null,readerCreator,cacheManager,null);
            CommentForumsActivityList activity = comments.GetCommentForumsActivity(minutes, "");

            VerifyActivityList(totalActiveForums, minutes, closeDate, startSampleTime, count, lastPostedDate, siteId, urlName, title, totalPosts, url, activity);

            cacheManager.AssertWasCalled(x => x.GetData(Arg<string>.Is.Anything));
            cacheManager.AssertWasCalled(x => x.Add(Arg<string>.Is.Anything, Arg<object>.Is.Anything, Arg<CacheItemPriority>.Is.Anything, Arg<ICacheItemRefreshAction>.Is.Anything, Arg<ICacheItemExpiration>.Is.Anything));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:31,代码来源:CommentForumActivityTests.cs

示例3: StartDateValueGreaterThan60Minutes_ReturnsActivityCappedAt60Minutes

        public void StartDateValueGreaterThan60Minutes_ReturnsActivityCappedAt60Minutes()
        {
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var reader = mocks.DynamicMock<IDnaDataReader>();
            var cacheManager = mocks.DynamicMock<ICacheManager>();

            DateTime requestedStartSampleTime = DateTime.Now.AddMinutes(-70); 
            DateTime expectedStartSampleTime = DateTime.Now.AddMinutes(-60);
            int expectedMinutes = 60;

            StubDatabaseCall(readerCreator, reader, 0, DateTime.Now, 0, DateTime.Now, 0, "", "", 0, "");

            mocks.ReplayAll();

            Comments comments = new Comments(null, readerCreator, cacheManager, null);
            CommentForumsActivityList activity = comments.GetCommentForumsActivity(1, requestedStartSampleTime.ToString());

            VerifyActivityList(0, expectedMinutes, DateTime.Now, expectedStartSampleTime, 0, DateTime.Now, 0, "", "", 0, "", activity);

            cacheManager.AssertWasCalled(x => x.GetData(Arg<string>.Is.Anything));
            cacheManager.AssertWasCalled(x => x.Add(Arg<string>.Is.Anything, Arg<object>.Is.Anything, Arg<CacheItemPriority>.Is.Anything, Arg<ICacheItemRefreshAction>.Is.Anything, Arg<ICacheItemExpiration>.Is.Anything));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:22,代码来源:CommentForumActivityTests.cs


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