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 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 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 DefaultScope() { // Arrange. var defaultScope = BlogPost.DefaultScope; BlogPost.DefaultScope = items => items.OrderBy(d => d.Title); BlogPost post1 = BlogPost.Create(new BlogPost { Title = "Z", }); BlogPost post2 = BlogPost.Create(new BlogPost { Title = "A", }); // Act. BlogPost retrievedPost = BlogPost.All().First(); // Assert. Assert.That(retrievedPost.ID, Is.EqualTo(post2.ID)); // Clean up. BlogPost.DefaultScope = defaultScope; }