本文整理汇总了C#中Comments.CommentForumCacheKey方法的典型用法代码示例。如果您正苦于以下问题:C# Comments.CommentForumCacheKey方法的具体用法?C# Comments.CommentForumCacheKey怎么用?C# Comments.CommentForumCacheKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments.CommentForumCacheKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommentForumReadByUid_CacheValid_ReturnsValidList
public void CommentForumReadByUid_CacheValid_ReturnsValidList()
{
var lastUpdate = DateTime.Now.AddDays(1);
var uid = "testUid";
var validForum = new CommentForum { Id = uid };
var comments = new Comments(null, null, null, null);
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 readerLastUpdate = mocks.DynamicMock<IDnaDataReader>();
var cacheManager = mocks.DynamicMock<ICacheManager>();
var siteName = "h2g2";
string cacheKey = comments.CommentForumCacheKey(uid, 0);
cacheManager.Stub(x => x.GetData(cacheKey + "|LASTUPDATED")).Return(lastUpdate);
cacheManager.Stub(x => x.GetData(cacheKey)).Return(validForum);
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.Once();
reader.Stub(x => x.GetStringNullAsEmpty("sitename")).Return(siteName);
readerComments.Stub(x => x.HasRows).Return(true);
readerComments.Stub(x => x.Read()).Return(true).Repeat.Once();
readerComments.Stub(x => x.GetInt32NullAsZero("totalresults")).Return(1);
readerLastUpdate.Stub(x => x.HasRows).Return(true);
readerLastUpdate.Stub(x => x.Read()).Return(true).Repeat.Once();
readerLastUpdate.Stub(x => x.GetDateTime("lastupdated")).Return(lastUpdate);
readerCreator.Stub(x => x.CreateDnaDataReader("commentforumreadbyuid")).Return(reader);
readerCreator.Stub(x => x.CreateDnaDataReader("commentsreadbyforumid")).Return(readerComments);
readerCreator.Stub(x => x.CreateDnaDataReader("CommentforumGetLastUpdate")).Return(readerLastUpdate);
siteList.Stub(x => x.GetSite(siteName)).Return(site);
mocks.ReplayAll();
comments = new Comments(null, readerCreator, cacheManager, siteList);
var forum = comments.GetCommentForumByUid(uid, site);
Assert.IsNotNull(forum);
Assert.AreEqual(uid, forum.Id);
readerCreator.AssertWasNotCalled(x => x.CreateDnaDataReader("commentforumreadbyuid"));
readerCreator.AssertWasNotCalled(x => x.CreateDnaDataReader("commentsreadbyforumid"));
}
示例2: CommentForumReadByUid_CacheInDateMissingActualObject_ReturnsValidList
public void CommentForumReadByUid_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 reader = mocks.DynamicMock<IDnaDataReader>();
var readerComments = mocks.DynamicMock<IDnaDataReader>();
var readerLastUpdate = mocks.DynamicMock<IDnaDataReader>();
var cacheManager = mocks.DynamicMock<ICacheManager>();
var siteName = "h2g2";
var uid = "";
string cacheKey = comments.CommentForumCacheKey("", 0);
cacheManager.Stub(x => x.GetData(cacheKey + "|LASTUPDATED")).Return(lastUpdate);
cacheManager.Stub(x => x.GetData(cacheKey)).Return(null);
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.Once();
reader.Stub(x => x.GetStringNullAsEmpty("sitename")).Return(siteName);
readerComments.Stub(x => x.HasRows).Return(true);
readerComments.Stub(x => x.Read()).Return(true).Repeat.Once();
readerComments.Stub(x => x.GetInt32NullAsZero("totalresults")).Return(1);
readerLastUpdate.Stub(x => x.HasRows).Return(true);
readerLastUpdate.Stub(x => x.Read()).Return(true).Repeat.Once();
readerLastUpdate.Stub(x => x.GetDateTime("lastupdated")).Return(lastUpdate);
readerCreator.Stub(x => x.CreateDnaDataReader("commentforumreadbyuid")).Return(reader);
readerCreator.Stub(x => x.CreateDnaDataReader("commentsreadbyforumid")).Return(readerComments);
readerCreator.Stub(x => x.CreateDnaDataReader("CommentforumGetLastUpdate")).Return(readerLastUpdate);
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 forum = comments.GetCommentForumByUid(uid, site);
Assert.IsNotNull(forum);
Assert.AreEqual(1, forum.commentList.TotalCount);
Assert.AreEqual(1, forum.commentList.comments.Count);
readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentforumreadbyuid"));
readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentsreadbyforumid"));
}