Esempio n. 1
0
        public void GetRecentEntries_WithFuturePosts_OnlyReturnsPastPosts()
        {
            // Arrange
            var repository = new DatabaseObjectProvider();
            DateTime utcNow = DateTime.UtcNow.AddDays(-2);
            var blog1 = UnitTestHelper.CreateBlogAndSetupContext(null, "subfolder1");
            var entryOne = UnitTestHelper.CreateAndSaveEntryForSyndication("me", "blog1-entry-one", "body-zero", null, utcNow, utcNow);
            var entryTwo = UnitTestHelper.CreateAndSaveEntryForSyndication("me", "blog1-entry-two", "body-zero", null, utcNow, utcNow.AddDays(10));
            var entryThree = UnitTestHelper.CreateAndSaveEntryForSyndication("me", "blog1-entry-three", "body-zero", null, utcNow, utcNow);
            var blog2 = UnitTestHelper.CreateBlogAndSetupContext(blog1.Host, "subfolder2");
            var entryFour = UnitTestHelper.CreateAndSaveEntryForSyndication("me", "blog2-entry-four", "body-zero", null, utcNow, utcNow.AddDays(10));
            var entryFive = UnitTestHelper.CreateAndSaveEntryForSyndication("me", "blog2-entry-five", "body-zero", null, utcNow, utcNow);

            UnitTestHelper.WriteTableToOutput("subtext_Config");
            UnitTestHelper.WriteTableToOutput("subtext_Content");
            // Act
            ICollection<Entry> entries = repository.GetRecentEntries(null, null, 10);

            // Assert (reverse ordering)
            Assert.AreEqual(3, entries.Count);
            Assert.AreEqual(entries.First().Id, entryFive.Id);
            Assert.AreEqual(entries.ElementAt(1).Id, entryThree.Id);
            Assert.AreEqual(entries.ElementAt(2).Id, entryOne.Id);
        }