コード例 #1
0
        public void TryAddPost_NotMatching_ReturnsFalse()
        {
            BlogPostPublished first = new BlogPostPublished
            {
                PageTitle     = "Title",
                DatePublished = new DateTime(2017, 1, 1)
            };

            BlogPostPublished second = new BlogPostPublished
            {
                PageTitle     = "Title",
                DatePublished = new DateTime(2017, 3, 1) // different month
            };

            MonthAndYearPostBucket bucket = new MonthAndYearPostBucket(first);

            Assert.IsFalse(bucket.TryAddPost(second));
        }
コード例 #2
0
        public void TryAddPost_NotMatching_DoesntAdd()
        {
            BlogPostPublished first = new BlogPostPublished
            {
                PageTitle     = "Title",
                DatePublished = new DateTime(2017, 1, 1)
            };

            BlogPostPublished second = new BlogPostPublished
            {
                PageTitle     = "Title",
                DatePublished = new DateTime(2017, 3, 1) // different month
            };

            MonthAndYearPostBucket bucket = new MonthAndYearPostBucket(first);

            bucket.TryAddPost(second);
            Assert.IsTrue(bucket.Posts.Count == 1);
            Assert.IsTrue(bucket.Posts[0].DatePublished == new DateTime(2017, 1, 1));
        }