public void EndEditShouldCompleteEditOperation() { // arrange var target = new MockEditableObject(); // act target.BeginEdit(); target.EndEdit(); // assert Assert.False( target.IsEditing ); }
public void EndEditShouldCommitChangesToObject() { // arrange var target = new MockEditableObject(); var createdDate = target.CreatedDate; // act target.Id = 1; target.FirstName = string.Empty; target.LastName = string.Empty; target.BeginEdit(); target.FirstName = "unit"; target.LastName = "test"; target.EndEdit(); // assert Assert.False( target.IsEditing ); Assert.Equal( 1, target.Id ); Assert.Equal( "unit", target.FirstName ); Assert.Equal( "test", target.LastName ); Assert.Equal( createdDate, target.CreatedDate ); }
public void AcceptChangesShouldCreateNewSavepoint() { // arrange var target = new MockEditableObject(); target.RecoveryModel = EditRecoveryModel.Full; target.Id = 5; target.FirstName = "bill"; target.LastName = "mei"; target.AcceptChanges(); // act target.BeginEdit(); target.FirstName = "john"; target.LastName = "doe"; target.EndEdit(); target.AcceptChanges(); target.BeginEdit(); target.FirstName = "jane"; target.LastName = "doe"; target.EndEdit(); target.RejectChanges(); // assert Assert.False( target.IsChanged ); Assert.Equal( "john", target.FirstName ); Assert.Equal( "doe", target.LastName ); }
public void IsChangedPropertyShouldBeTrueUntilAcceptChangesIsInvoked() { var target = new MockEditableObject(); Assert.False( target.IsChanged ); target.BeginEdit(); target.Id = 5; target.LastName = "bill"; target.FirstName = "mei"; target.CancelEdit(); // initial state was unchanged, so it should still be unchanged Assert.False( target.IsChanged ); target.BeginEdit(); target.Id = 10; target.LastName = "john"; target.FirstName = "doe"; target.EndEdit(); // change committed, so it should now be changed Assert.True( target.IsChanged ); target.BeginEdit(); target.Id = 20; target.LastName = "jane"; target.FirstName = "doe"; target.CancelEdit(); // although previous edit was canceled, the object was already the // changed state. it should, therfore, still be in the changed state Assert.True( target.IsChanged ); target.AcceptChanges(); Assert.False( target.IsChanged ); }