本文整理汇总了C#中Subtext.Framework.Data.DatabaseObjectProvider.GetPreviousAndNextEntries方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseObjectProvider.GetPreviousAndNextEntries方法的具体用法?C# DatabaseObjectProvider.GetPreviousAndNextEntries怎么用?C# DatabaseObjectProvider.GetPreviousAndNextEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subtext.Framework.Data.DatabaseObjectProvider
的用法示例。
在下文中一共展示了DatabaseObjectProvider.GetPreviousAndNextEntries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPreviousAndNextBasedOnSyndicationDateNotEntryId
public void GetPreviousAndNextBasedOnSyndicationDateNotEntryId()
{
var repository = new DatabaseObjectProvider();
string hostname = UnitTestHelper.GenerateUniqueString();
repository.CreateBlog("", "username", "password", hostname, string.Empty);
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty);
BlogRequest.Current.Blog = repository.GetBlog(hostname, string.Empty);
Entry previousEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body");
Entry currentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body");
Entry nextEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body");
previousEntry.IsActive = false;
currentEntry.IsActive = false;
nextEntry.IsActive = false;
//Create out of order.
int currentId = UnitTestHelper.Create(currentEntry);
int nextId = UnitTestHelper.Create(nextEntry);
int previousId = UnitTestHelper.Create(previousEntry);
//Now syndicate.
previousEntry.IsActive = true;
var subtextContext = new Mock<ISubtextContext>();
subtextContext.Setup(c => c.Blog).Returns(Config.CurrentBlog);
subtextContext.Setup(c => c.Repository).Returns(repository);
UnitTestHelper.Update(previousEntry, subtextContext.Object);
Thread.Sleep(100);
currentEntry.IsActive = true;
UnitTestHelper.Update(currentEntry, subtextContext.Object);
Thread.Sleep(100);
nextEntry.IsActive = true;
UnitTestHelper.Update(nextEntry, subtextContext.Object);
Assert.IsTrue(previousId > currentId, "Ids are out of order.");
var entries = repository.GetPreviousAndNextEntries(currentId, PostType.BlogPost);
Assert.AreEqual(2, entries.Count, "Expected both previous and next.");
//The first should be next because of descending sort.
Assert.AreEqual(nextId, entries.First().Id, "The next entry does not match expectations.");
Assert.AreEqual(previousId, entries.ElementAt(1).Id, "The previous entry does not match expectations.");
}
示例2: GetPreviousAndNextEntriesReturnsBoth
public void GetPreviousAndNextEntriesReturnsBoth()
{
var repository = new DatabaseObjectProvider();
string hostname = UnitTestHelper.GenerateUniqueString();
repository.CreateBlog("", "username", "password", hostname, string.Empty);
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty);
BlogRequest.Current.Blog = repository.GetBlog(hostname, string.Empty);
Entry previousEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow.AddDays(-2));
Entry currentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow.AddDays(-1));
Entry nextEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow);
int previousId = UnitTestHelper.Create(previousEntry);
Thread.Sleep(100);
int currentId = UnitTestHelper.Create(currentEntry);
Thread.Sleep(100);
int nextId = UnitTestHelper.Create(nextEntry);
var entries = repository.GetPreviousAndNextEntries(currentId,
PostType.BlogPost);
Assert.AreEqual(2, entries.Count, "Expected both previous and next.");
//The more recent one is next because of desceding sort.
Assert.AreEqual(nextId, entries.First().Id, "The next entry does not match expectations.");
Assert.AreEqual(previousId, entries.ElementAt(1).Id, "The previous entry does not match expectations.");
}
示例3: GetPreviousAndNextEntriesReturnsPreviousWhenNoNextExists
public void GetPreviousAndNextEntriesReturnsPreviousWhenNoNextExists()
{
string hostname = UnitTestHelper.GenerateUniqueString();
var repository = new DatabaseObjectProvider();
repository.CreateBlog("", "username", "password", hostname, string.Empty);
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty);
BlogRequest.Current.Blog = repository.GetBlog(hostname, string.Empty);
Entry previousEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow.AddDays(-1));
Entry currentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow);
int previousId = UnitTestHelper.Create(previousEntry);
int currentId = UnitTestHelper.Create(currentEntry);
var entries = repository.GetPreviousAndNextEntries(currentId,
PostType.BlogPost);
Assert.AreEqual(1, entries.Count, "Since there is no next entry, should return only 1");
Assert.AreEqual(previousId, entries.First().Id, "The previous entry does not match expectations.");
}