Exemple #1
0
        public void CanGetPostsByYearArchive()
        {
            DateTime utcNow = DateTime.ParseExact("2009/08/15 11:00 PM", "yyyy/MM/dd hh:mm tt", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal).ToUniversalTime();

            UnitTestHelper.SetupBlog();
            var repository = new DatabaseObjectProvider();
            ICollection<ArchiveCount> counts = repository.GetPostCountsByYear();
            Assert.AreEqual(0, counts.Count);

            Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title", "body");
            entry.DatePublishedUtc = utcNow;
            UnitTestHelper.Create(entry);
            counts = repository.GetPostCountsByYear();
            Assert.AreEqual(1, counts.Count);

            foreach (ArchiveCount archiveCount in counts)
            {
                Console.WriteLine("archiveCount.Date: " + archiveCount.Date);

                Assert.AreEqual(1, archiveCount.Count, "Expected one post in the archive.");
                Assert.AreEqual(utcNow.Year, archiveCount.Date.Year);
                return;
            }
        }