public void FindOneReturnsNullIfNoMatch() { // Act. BlogPost myPost = BlogPost.Find(u => u.Title == "My Blog Post"); // Assert. Assert.That(myPost, Is.Null); }
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 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 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")); }