public void AddCommentToUnsavedPostThrowsInvalidOperationException()
 {
     var post = new Post
     {
         Title = "The Not Lonely Post"
     };
     var repository = new PostRepository(_db);
     Assert.That(() => repository.AddComment(post, new Comment
                                     {
                                         Content = "Here I am!"
                                     }), Throws.InvalidOperationException);
 }
 public void AddCommentAddsComment()
 {
     var post = new Post
                    {
                        Title = "The Not Lonely Post"
                    };
     _db.GetCollection<Post>("posts").Insert(post);
     var repository = new PostRepository(_db);
     repository.AddComment(post, new Comment
                                     {
                                         Content = "Here I am!"
                                     });
     var posts = (from p in _db.GetCollection<Post>("posts").AsQueryable<Post>()
                   where p.Title == "The Not Lonely Post"
                   select p).ToArray();
     Assert.That(posts, Has.Exactly(1).Not.Null);
     Assert.That(posts, Has.Exactly(0).Null);
     var comments = posts[0].Comments;
     Assert.That(comments, Is.Not.Null);
     Assert.That(comments, Has.Exactly(1).Not.Null);
     Assert.That(comments, Has.Exactly(0).Null);
     Assert.That(comments[0].Content, Is.EqualTo("Here I am!"));
 }