public void MBlogRepository_InsertOrUpdatePost_ShouldInsertPost() { var context = new TestDbContext(); var repo = new MBlogRepository(context); var post = new Post() { Title = "Test Title", }; repo.AddPost(post); Assert.AreEqual(1, context.Posts.Count()); }
public void MBlogRepository_InsertOrUpdatePost_ShouldUpdatePost() { var context = new TestDbContext(); var repo = new MBlogRepository(context); var newTitle = "NewTitle"; var post = new Post() { Title = "Test Title", }; var post2 = post; post2.Title = newTitle; repo.AddPost(post); repo.AddPost(post2); Assert.AreEqual(1, context.Posts.Count()); Assert.AreEqual(newTitle, context.Posts.ToArray()[0].Title); }