public void Dispose_WithBlogHavingDuplicateCommentsEnabled_DoesNotChangeBlog() { // arrange var blog = new Blog { DuplicateCommentsEnabled = true }; var repository = new Mock<ObjectRepository>(); repository.Setup(r => r.UpdateBlog(blog)).Throws(new InvalidOperationException()); var scope = new BlogImportSetup(blog, repository.Object); // act scope.Dispose(); // assert Assert.IsTrue(blog.DuplicateCommentsEnabled); }
public void Dispose_WithBlogHavingDuplicateCommentsDisabled_DisablesDuplicateCommentsAgain() { // arrange var blog = new Blog { DuplicateCommentsEnabled = false }; var repository = new Mock<ObjectRepository>(); bool updateCalled = false; var scope = new BlogImportSetup(blog, repository.Object); repository.Setup(r => r.UpdateBlog(blog)).Callback(() => updateCalled = true); // act scope.Dispose(); // assert Assert.IsFalse(blog.DuplicateCommentsEnabled); Assert.IsTrue(updateCalled); }