public void CanSaveAndReadBlogWithComments() { var blog = new Blog { Title = "title", Body = "Body" }; blog.AddComment(new Comment(){Author = "Marcel",Body="Body"}); blogRepository.Session.Save(blog); reset(); Debug.WriteLine("Before Getting Blog"); var fromDb = blogRepository.Blogs.Single(b=>b.Id==blog.Id); Debug.WriteLine("Before reading Blog property"); Assert.AreEqual("title",fromDb.Title); Debug.WriteLine("Before reading comments"); Assert.AreEqual(1, fromDb.Comments.ToList().Count); }
public void CanCreateBlogWithComments() { var blog = new Blog {Body = "Body", Title = "Title"}; blog.AddComment(new Comment {Author="Author", Body="Body"}); Assert.AreEqual(1,blog.Comments.ToList().Count); }
public void Populate() { var session=this.Session; using(var transaction = session.BeginTransaction()) { for (int i = 0; i < 100; i++) { var blog = new Blog{Body = "Body" + i, Title = "Title" + i}; for (int j = 0; j < 5; j++) { var comment = new Comment {Author = "Fredek" + j, Body = "Comment Body" + j, Blog = blog}; blog.AddComment(comment); } session.Save(blog); } transaction.Commit(); } session.Close(); }