コード例 #1
0
        public void Can_Persist_Joins()
        {
            Initialize(true);

            using (var repository = new NHibernateBlogService())
            {
                var post = DummyLivePost();

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

                post.Categories.Add(category);

                repository.Save(post);
                repository.Save(category);

                Assert.AreEqual(1, repository.GetPosts().Count);
            }

            using (var repository = new NHibernateBlogService())
            {
                Assert.AreEqual(1, repository.GetPosts().Count);
                Assert.AreEqual(1, repository.GetCategories().Count);

                var post = repository.GetPosts().First();
                Assert.AreEqual(1, post.Categories.Count);
            }
        }
コード例 #2
0
        public void Can_Save_Post_With_Category_Attached()
        {
            Initialize(true);

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

                var post = DummyLivePost();

                post.Categories.Add(category);

                repository.Save(post);
                repository.Save(category);

                Assert.AreEqual(1, repository.GetPosts().Count);
                Assert.AreEqual(1, repository.GetCategories().Count);
            }
        }
コード例 #3
0
        public void Can_Load_Saved_Category()
        {
            Initialize(true);

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

                repository.Save(category);

                Assert.AreEqual(1, repository.GetCategories().Count);
            }
        }