Пример #1
0
        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 );
        }
Пример #2
0
        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 );
        }
Пример #3
0
        public void AcceptChangesShouldSignalNoChanges()
        {
            // arrange
            var target = new MockEditableObject();

            target.Id = 5;
            target.LastName = "bill";
            target.FirstName = "mei";

            // act
            var changed = target.IsChanged;
            target.AcceptChanges();

            // assert
            Assert.True( changed );
            Assert.False( target.IsChanged );
        }