public void Rollback_ChangedCollectionReference() { _collectionManagerMock.Stub(stub => stub.HasCollectionReferenceChanged()).Return(true); _collectionManagerMock.Expect(mock => mock.RollbackCollectionReference()); _collectionManagerMock.Replay(); _loadStateMock.Stub(stub => stub.HasChanged()).Return(false); _loadStateMock.Expect(mock => mock.Rollback(_endPoint)); _loadStateMock.Replay(); _endPoint.Touch(); Assert.That(_endPoint.HasBeenTouched, Is.True); _endPoint.Rollback(); _collectionManagerMock.VerifyAllExpectations(); _loadStateMock.VerifyAllExpectations(); Assert.That(_endPoint.HasBeenTouched, Is.False); }
public void CollectionEndPoint_ReplacedCollection() { var newOpposites = _endPoint.Collection.Clone(); _endPoint.CreateSetCollectionCommand(newOpposites).ExpandToAllRelatedObjects().NotifyAndPerform(); CollectionEndPoint deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint); Assert.That(deserializedEndPoint.HasChanged, Is.True); var deserializedNewOpposites = deserializedEndPoint.Collection; deserializedEndPoint.Rollback(); Assert.That(deserializedEndPoint.HasChanged, Is.False); var deserializedOldOpposites = deserializedEndPoint.Collection; Assert.That(deserializedOldOpposites, Is.Not.SameAs(deserializedNewOpposites)); Assert.That(deserializedOldOpposites, Is.Not.Null); }
public void Rollback_AfterReplace_RestoresPreviousReference() { var oldOpposites = _customerEndPoint.Collection; var newOpposites = new OrderCollection { _order3 }; SetCollectionAndNotify(_customerEndPoint, newOpposites); // replace collection _customerEndPoint.Rollback(); Assert.That(_customerEndPoint.Collection, Is.SameAs(oldOpposites)); Assert.That(_customerEndPoint.Collection, Is.EqualTo(new[] { _order1, _order2 })); }