當前位置: 首頁>>代碼示例>>C#>>正文


C# DatabaseObjectProvider.GetBlogPostsForHomePage方法代碼示例

本文整理匯總了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);
        }
開發者ID:rsaladrigas,項目名稱:Subtext,代碼行數:35,代碼來源:EntryDayGetTests.cs

示例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.
        }
開發者ID:rsaladrigas,項目名稱:Subtext,代碼行數:46,代碼來源:EntryDayGetTests.cs

示例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);
        }
開發者ID:rsaladrigas,項目名稱:Subtext,代碼行數:48,代碼來源:EntryDayGetTests.cs

示例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);
        }
開發者ID:rsaladrigas,項目名稱:Subtext,代碼行數:42,代碼來源:EntryDayGetTests.cs


注:本文中的Subtext.Framework.Data.DatabaseObjectProvider.GetBlogPostsForHomePage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。