public void service_revert_to_a_bookmark_created_by_another_service() { ChangeTrackingService svc1 = new ChangeTrackingService(); IBookmark bmk = svc1.CreateBookmark(); ChangeTrackingService svc2 = new ChangeTrackingService(); svc2.Revert( bmk ); }
public void service_successfully_revert_to_a_valid_bookmark_created_at_initial_state() { String expected = String.Empty; ChangeTrackingService svc = new ChangeTrackingService(); IBookmark bmk = svc.CreateBookmark(); Person p = new Person( svc ); p.Name = "foo.."; p.Name = "foo once again..."; svc.Revert( bmk ); Assert.AreEqual<String>( expected, p.Name ); }
public void changeTrackingService_revert_normal_entity_registered_transient_with_no_autoRemove_and_changes_before_bookmark_creation_should_remain_transient() { var expected = EntityTrackingStates.IsTransient | EntityTrackingStates.HasBackwardChanges; var memento = new ChangeTrackingService(); var person = new Person( memento, false ); memento.RegisterTransient( person, false ); person.Name = "Mauro"; var bookmark = memento.CreateBookmark(); new Person( memento, true ); memento.Revert( bookmark ); var actual = memento.GetEntityState( person ); actual.Should().Be.EqualTo( expected ); }
public void service_revert_with_a_null_bookmark() { ChangeTrackingService svc = new ChangeTrackingService(); svc.Revert( null ); }
public void changeTrackingService_revert_normal_entity_registered_transient_with_no_autoRemove_and_no_changes_after_bookmark_creation_is_still_transient() { var expected = EntityTrackingStates.IsTransient; var memento = new ChangeTrackingService(); var bookmark = memento.CreateBookmark(); var person = new Person( memento, false ); memento.RegisterTransient( person, false ); memento.Revert( bookmark ); var actual = memento.GetEntityState( person ); actual.Should().Be.EqualTo( expected ); }
public void changeTrackingService_revert_normal_entity_registered_transient_with_changes_after_bookmark_creation_is_no_more_transient() { var expected = EntityTrackingStates.None; var memento = new ChangeTrackingService(); var bookmark = memento.CreateBookmark(); var person = new Person( memento, true ); person.Name = "Mauro"; memento.Revert( bookmark ); var actual = memento.GetEntityState( person ); actual.Should().Be.EqualTo( expected ); }
public void service_on_revert_with_nothing_to_do_not_raise_trackingServiceStateChanged_event() { Int32 expected = 0; Int32 actual = 0; ChangeTrackingService svc = new ChangeTrackingService(); Person p = new Person( svc ); var bmk = svc.CreateBookmark(); svc.TrackingServiceStateChanged += ( s, e ) => { actual++; }; svc.Revert( bmk ); Assert.AreEqual<Int32>( expected, actual ); }
public void service_cannot_revert_to_an_invalid_bookmark() { ChangeTrackingService svc = new ChangeTrackingService(); Person p = new Person( svc ); p.Name = "Mauro"; var bmk = svc.CreateBookmark(); svc.Undo(); svc.Revert( bmk ); }
public void service_successfully_revert_to_a_valid_bookmark_created_at_initial_state_and_entity_is_no_more_transient() { EntityTrackingStates expected = EntityTrackingStates.None; ChangeTrackingService svc = new ChangeTrackingService(); IBookmark bmk = svc.CreateBookmark(); Person p = new Person( svc ); p.Name = "foo.."; p.Name = "foo once again..."; svc.Revert( bmk ); EntityTrackingStates actual = svc.GetEntityState( p ); Assert.AreEqual<EntityTrackingStates>( expected, actual ); }