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 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)); }