Exemplo n.º 1
0
        public void APostWithMultipleComments_OnlyReturnsOnePost()
        {
            Initialize(true);
            using (var repository = new NHibernateBlogService())
            {
                var post = DummyLivePost();

                for (int i = 0; i < 5; i++)
                {
                    var comment = new Comment()
                    {
                        Name="tetst",
                        Content="Comment2"
                    };

                    post.Comments.Add(comment);

                    repository.Save(comment);
                }

                repository.Save(post);

            }
            using (var repository = new NHibernateBlogService())
            {
                Assert.AreEqual(1, repository.GetPublishedPosts().Count);
            }
        }
Exemplo n.º 2
0
        public void Can_Return_Published_Posts()
        {
            Initialize(true);

            using (var repository = new NHibernateBlogService())
            {
                for (int i = 0; i < 5; i++)
                {
                    var post = DummyLivePost();

                    repository.Save(post);
                }

                for (int i = 0; i < 5; i++)
                {
                    var post = DummyLivePost();

                    post.IsPublished = false;

                    repository.Save(post);
                }
            }
            using (var repository = new NHibernateBlogService())
            {
                Assert.AreEqual(5, repository.GetPublishedPosts().Count);
            }
        }