public void ShouldRollbackChangesToObject() { // arrange var obj = new MockEditableObject(); var transaction = new FieldTransaction( obj, new[] { "LastModified" } ); var lastModified = obj.LastModified; // act transaction.Begin(); obj.LastModified = DateTime.Now; transaction.Rollback(); // assert Assert.Equal( lastModified, obj.LastModified ); }
public void ShouldNotRollbackUnstartedTransaction() { var target = new FieldTransaction( new MockEditableObject() ); Assert.Throws<InvalidOperationException>( () => target.Rollback() ); }
public void ShouldNotSupportBeginNestedTransaction() { var target = new FieldTransaction( new MockEditableObject() ); target.Begin(); Assert.Throws<InvalidOperationException>( () => target.Begin() ); }