public void CanSaveExistingBlogPost() { // Arrange. BlogPost post = CreateBlogPost(); post.Save(); // Act. post.Text = "My New Title"; post.Save(); // Assert. Assert.That(BlogPost.All().Count(), Is.EqualTo(1)); }
public void CanSaveNewBlogPost() { // Act. BlogPost post = CreateBlogPost(); post.Save(); // Assert. Assert.That(post.ID, Is.Not.EqualTo(ObjectId.Empty)); }
public void CanDeleteBlogPost() { // Arrange. BlogPost post = CreateBlogPost(); post.Save(); // Act. BlogPost.Delete(post.ID); // Assert. Assert.That(BlogPost.All().Count(), Is.EqualTo(0)); }
public void CanDestroyBlogPost() { // Arrange. BlogPost post = CreateBlogPost(); post.Save(); // Act. post.Destroy(); // Assert. Assert.That(post.IsDestroyed, Is.True); }
public void CanFindBlogPostByID() { // Arrange. BlogPost post = CreateBlogPost(); post.Save(); // Act. BlogPost myPost = BlogPost.Find(post.ID); // Assert. Assert.That(myPost.Text, Is.EqualTo("Some text")); }
public void CanFindBlogPostByPredicate() { // Arrange. BlogPost post = CreateBlogPost(); post.Save(); // Act. BlogPost myPost = BlogPost.Find(u => u.Title == "My Blog Post"); // Assert. Assert.That(myPost, Is.Not.Null); Assert.That(myPost.Text, Is.EqualTo("Some text")); }
public void IncUpdatesDatabaseAndLocalValuesForSimpleProperty() { // Arrange. BlogPost post = CreateBlogPost(); post.ReadCount = 3; post.Save(); // Act. post.Inc(p => p.ReadCount, 1); // Assert. Assert.That(post.ReadCount, Is.EqualTo(4)); Assert.That(BlogPost.Find(post.ID).ReadCount, Is.EqualTo(4)); }
public void CanFindAllBlogPosts() { // Arrange. BlogPost post1 = CreateBlogPost(); post1.Save(); BlogPost post2 = CreateBlogPost(); post2.Save(); // Act. var allPosts = BlogPost.All(); // Assert. Assert.That(allPosts.Count(), Is.EqualTo(2)); }
public void CanDeleteAllBlogPost() { // Arrange. BlogPost post1 = CreateBlogPost(); post1.Save(); BlogPost post2 = CreateBlogPost(); post2.Save(); // Act. Assert.That(BlogPost.All().Count(), Is.EqualTo(2)); BlogPost.DeleteAll(); // Assert. Assert.That(BlogPost.All().Count(), Is.EqualTo(0)); }
public void CanFindBlogPostsByPredicate() { // Arrange. BlogPost post1 = CreateBlogPost(); post1.Save(); BlogPost post2 = CreateBlogPost(); post2.Save(); // Act. var blogPosts = BlogPost.Where(u => u.Title == "My Blog Post"); // Assert. Assert.That(blogPosts, Is.Not.Null); Assert.That(blogPosts.ToList(), Has.Count.EqualTo(2)); }
public void CanPullComment() { // Arrange. BlogPost post = CreateBlogPost(); post.Comments.Add(new Comment { Date = DateTime.Now, Name = "Tim Jones" }); post.Save(); // Act. BlogPost.Pull(post.ID, p => p.Comments, c => c.Name == "Tim Jones"); // Assert. BlogPost myPost = BlogPost.Find(post.ID); Assert.That(myPost.Comments.Count, Is.EqualTo(0)); }
public void CanFindBlogPostsByAuthor() { // Arrange. var authorID = ObjectId.GenerateNewId(); BlogPost post1 = CreateBlogPost(); post1.Authors = new System.Collections.Generic.List <ObjectId> { authorID }; post1.Save(); BlogPost post2 = CreateBlogPost(); post2.Save(); // Act. var matchingPosts = BlogPost.Where(bp => bp.Authors.Contains(authorID)).QueryDump(Log).ToList(); // Assert. Assert.That(matchingPosts.Count, Is.EqualTo(1)); }
public void CanPushComment() { // Arrange. BlogPost post = CreateBlogPost(); post.Save(); // Act. var comment = new Comment { Date = DateTime.Now, Name = "Tim Jones" }; BlogPost.Push(post.ID, p => p.Comments, comment); // Assert. BlogPost myPost = BlogPost.Find(post.ID); Assert.That(myPost.Comments.Count, Is.EqualTo(1)); Assert.That(myPost.Comments[0].Name, Is.EqualTo("Tim Jones")); }