本文整理汇总了C#中Subtext.Framework.Data.DatabaseObjectProvider.GetBlogPostsForHomePage方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseObjectProvider.GetBlogPostsForHomePage方法的具体用法?C# DatabaseObjectProvider.GetBlogPostsForHomePage怎么用?C# DatabaseObjectProvider.GetBlogPostsForHomePage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subtext.Framework.Data.DatabaseObjectProvider
的用法示例。
在下文中一共展示了DatabaseObjectProvider.GetBlogPostsForHomePage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBlogPostsReturnsActiveOnlyAndNoneInFuture
public void GetBlogPostsReturnsActiveOnlyAndNoneInFuture()
{
//Create some entries.
var repository = new DatabaseObjectProvider();
Entry entryZero = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-zero", "body-zero");
entryZero.IsActive = entryZero.IncludeInMainSyndication = true;
Entry entryOne = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-one", "body-one");
entryOne.IsActive = entryOne.IncludeInMainSyndication = true;
entryOne.DateCreatedUtc = DateTime.UtcNow.AddDays(-1);
entryOne.DatePublishedUtc = DateTime.UtcNow.AddDays(-1);
Entry entryTwo = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
entryTwo.IsActive = false;
Entry entryThree = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-three", "body-zero");
entryThree.IsActive = entryThree.IncludeInMainSyndication = true;
entryThree.DateCreatedUtc.AddDays(-2);
entryThree.DatePublishedUtc = DateTime.UtcNow.AddDays(10);
//Persist entries.
UnitTestHelper.Create(entryZero);
Thread.Sleep(500);
UnitTestHelper.Create(entryOne);
Thread.Sleep(500);
UnitTestHelper.Create(entryTwo);
Thread.Sleep(500);
UnitTestHelper.Create(entryThree);
Assert.IsTrue(entryThree.DatePublishedUtc > DateTime.UtcNow);
//Get EntryDay
ICollection<EntryDay> entryList = repository.GetBlogPostsForHomePage(10, PostConfig.IsActive).ToList();
//Test outcome
Assert.AreEqual(2, entryList.Count);
Assert.AreEqual(1, entryList.First().Count);
Assert.AreEqual(1, entryList.ElementAt(1).Count);
}
示例2: GetBlogPostsReturnsAllPostsIfPostConfigNoneSpecified
public void GetBlogPostsReturnsAllPostsIfPostConfigNoneSpecified()
{
// Create four entries.
var repository = new DatabaseObjectProvider();
Entry entryZero = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-zero", "body-zero");
entryZero.IsActive = entryZero.IncludeInMainSyndication = true;
Entry entryOne = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-one", "body-one");
entryOne.IsActive = entryOne.IncludeInMainSyndication = true;
Entry entryTwo = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
entryTwo.IsActive = false;
Entry entryThree = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-three", "body-zero");
entryThree.IncludeInMainSyndication = true;
entryThree.IsActive = true;
entryThree.DateCreatedUtc = DateTime.UtcNow.AddDays(10);
entryThree.DatePublishedUtc = DateTime.UtcNow.AddDays(10);
//Persist entries.
UnitTestHelper.Create(entryZero);
Thread.Sleep(500);
UnitTestHelper.Create(entryOne);
Thread.Sleep(500);
UnitTestHelper.Create(entryTwo);
Thread.Sleep(500);
UnitTestHelper.Create(entryThree);
Assert.IsTrue(entryThree.DatePublishedUtc > DateTime.UtcNow);
//Get EntryDay
ICollection<EntryDay> entryList = repository.GetBlogPostsForHomePage(10, PostConfig.None).ToList();
//Test outcome
Assert.AreEqual(3, entryList.Count);
foreach (var entryDay in entryList)
{
Console.WriteLine("Entry Day: " + entryDay.Count + " " + entryDay.BlogDay);
foreach (var item in entryDay)
{
Console.WriteLine("\tEntry: " + item.Id);
}
}
Assert.AreEqual(1, entryList.First().Count);
Assert.AreEqual(2, entryList.ElementAt(1).Count);
Assert.AreEqual(1, entryList.ElementAt(2).Count); // One of these don't have a date syndicated.
}
示例3: GetHomePageEntriesReturnsDaysWithEnclosure
public void GetHomePageEntriesReturnsDaysWithEnclosure()
{
//Create some entries.
Entry entryZero = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-zero", "body-zero");
entryZero.DatePublishedUtc = DateTime.UtcNow.AddDays(-1);
entryZero.IsActive = entryZero.IncludeInMainSyndication = true;
Thread.Sleep(100);
Entry entryOne = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-one", "body-one");
entryOne.DatePublishedUtc = DateTime.UtcNow.AddDays(-1);
entryOne.IsActive = entryOne.IncludeInMainSyndication = true;
Thread.Sleep(100);
Entry entryTwo = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
entryTwo.DisplayOnHomePage = false;
Thread.Sleep(100);
Entry entryThree = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
entryThree.IsActive = entryThree.IncludeInMainSyndication = true;
//Persist entries.
UnitTestHelper.Create(entryZero);
UnitTestHelper.Create(entryOne);
UnitTestHelper.Create(entryTwo);
UnitTestHelper.Create(entryThree);
var repository = new DatabaseObjectProvider();
//Add Enclosure
Enclosure enc = UnitTestHelper.BuildEnclosure("Nothing to see here.", "httP://blablabla.com", "audio/mp3",
entryZero.Id, 12345678, true, true);
repository.Create(enc);
//Get EntryDay
ICollection<EntryDay> entryList = repository.GetBlogPostsForHomePage(10, PostConfig.DisplayOnHomepage | PostConfig.IsActive).ToList();
var days = new EntryDay[2];
entryList.CopyTo(days, 0);
//Test outcome
Assert.AreEqual(2, entryList.Count, "Expected to find two days.");
EntryDay entries = days[1];
Assert.AreEqual(2, entries.Count, "Expected to find two entries.");
Assert.AreEqual(entries.First().Id, entryOne.Id, "Ordering is off.");
Assert.AreEqual(entries.ElementAt(1).Id, entryZero.Id, "Ordering is off.");
Assert.IsNull(entries.First().Enclosure, "Entry should not have enclosure.");
Assert.IsNotNull(entries.ElementAt(1).Enclosure, "Entry should have enclosure.");
UnitTestHelper.AssertEnclosures(enc, entries.ElementAt(1).Enclosure);
}
示例4: GetBlogPostsReturnsDaysWithEnclosure
public void GetBlogPostsReturnsDaysWithEnclosure()
{
//Create some entries.
Entry entryZero = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-zero", "body-zero");
Thread.Sleep(500);
Entry entryOne = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-one", "body-one");
Thread.Sleep(500);
Entry entryTwo = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
entryTwo.IsActive = false;
Thread.Sleep(500);
Entry entryThree = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-three", "body-three");
//Persist entries.
UnitTestHelper.Create(entryZero);
UnitTestHelper.Create(entryOne);
UnitTestHelper.Create(entryTwo);
UnitTestHelper.Create(entryThree);
Assert.IsTrue(entryZero.DateCreatedUtc < entryOne.DateCreatedUtc);
Assert.IsTrue(entryOne.DateCreatedUtc < entryTwo.DateCreatedUtc);
Assert.IsTrue(entryTwo.DateCreatedUtc < entryThree.DateCreatedUtc);
var repository = new DatabaseObjectProvider();
//Add Enclosure
Enclosure enc = UnitTestHelper.BuildEnclosure("Nothing to see here.", "httP://blablabla.com", "audio/mp3",
entryZero.Id, 12345678, true, true);
repository.Create(enc);
//Get EntryDay
ICollection<EntryDay> entryList = repository.GetBlogPostsForHomePage(10, PostConfig.IsActive).ToList();
Collection<Entry> entries = entryList.First();
//Test outcome
Assert.AreEqual(1, entryList.Count, "Expected to find one entry day.");
Assert.AreEqual(3, entries.Count, "Expected to find three entries.");
Assert.IsNull(entries.First().Enclosure, "Entry should not have enclosure.");
Assert.IsNull(entries.ElementAt(1).Enclosure, "Entry should not have enclosure.");
Assert.IsNotNull(entries.ElementAt(2).Enclosure, "Entry should have enclosure.");
UnitTestHelper.AssertEnclosures(enc, entries.ElementAt(2).Enclosure);
}