Exemplo n.º 1
0
        public void Can_Return_Published_Posts_By_Category()
        {
            Initialize(true);

            using (var repository = new NHibernateBlogService())
            {
                var category = new Category() { Name = "Test" };

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

                    post.Categories.Add(category);

                    repository.Save(post);
                }

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

                    post.IsPublished = false;
                    post.Categories.Add(category);

                    repository.Save(post);
                }
                repository.Save(category);
            }
            using (var repository = new NHibernateBlogService())
            {
                Assert.AreEqual(10, repository.GetPostsByCategory(1).Count);
                Assert.AreEqual(5, repository.GetPublishedPostsByCategory(1).Count);
            }
        }