public void ResurrectInvalidObject() { Assert.That(TestableClientTransaction.IsInvalid(_invalidObject.ID), Is.True); ResurrectionService.ResurrectInvalidObject(TestableClientTransaction, _invalidObject.ID); Assert.That(TestableClientTransaction.IsInvalid(_invalidObject.ID), Is.False); }
public void DiscardedNewObject() { var newObject = Order.NewObject(); newObject.Delete(); CheckStateIsInvalid(newObject, TestableClientTransaction); ResurrectionService.ResurrectInvalidObject(TestableClientTransaction, newObject.ID); CheckStateIsNotInvalid(newObject, TestableClientTransaction, StateType.NotLoadedYet); }
public void UnloadDataInReadOnlyMiddleTransaction_IsAllowed() { CheckState(ReadOnlyRootTransaction, _invalidOrder, StateType.Invalid); CheckState(ReadOnlyMiddleTransaction, _invalidOrder, StateType.Invalid); CheckState(WriteableSubTransaction, _invalidOrder, StateType.Invalid); ResurrectionService.ResurrectInvalidObject(ReadOnlyMiddleTransaction, _invalidOrder.ID); CheckState(ReadOnlyRootTransaction, _invalidOrder, StateType.NotLoadedYet); CheckState(ReadOnlyMiddleTransaction, _invalidOrder, StateType.NotLoadedYet); CheckState(WriteableSubTransaction, _invalidOrder, StateType.NotLoadedYet); }
public void NotFoundObject() { var notFoundID = new ObjectID(typeof(Order), Guid.NewGuid()); var notFoundObject = LifetimeService.GetObjectReference(TestableClientTransaction, notFoundID); notFoundObject.TryEnsureDataAvailable(); CheckStateIsInvalid(notFoundObject, TestableClientTransaction); ResurrectionService.ResurrectInvalidObject(TestableClientTransaction, notFoundID); CheckStateIsNotInvalid(notFoundObject, TestableClientTransaction, StateType.NotLoadedYet); }
public void DiscardedDeletedObject() { SetDatabaseModifyable(); var deletedObject = DomainObjectIDs.ClassWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); deletedObject.Delete(); TestableClientTransaction.Commit(); CheckStateIsInvalid(deletedObject, TestableClientTransaction); ResurrectionService.ResurrectInvalidObject(TestableClientTransaction, deletedObject.ID); CheckStateIsNotInvalid(deletedObject, TestableClientTransaction, StateType.NotLoadedYet); }
public void InvalidObject() { var domainObject = ClassWithAllDataTypes.NewObject(); domainObject.Delete(); Assert.That(domainObject.State, Is.EqualTo(StateType.Invalid)); Assert.That(() => domainObject.RegisterForCommit(), Throws.TypeOf <ObjectInvalidException> ()); Assert.That(domainObject.State, Is.EqualTo(StateType.Invalid)); ResurrectionService.ResurrectInvalidObject(TestableClientTransaction, domainObject.ID); Assert.That(domainObject.State, Is.EqualTo(StateType.NotLoadedYet)); }
public void ResurrectInvalidObject_Hierarchy() { var subTransaction = TestableClientTransaction.CreateSubTransaction(); using (subTransaction.EnterDiscardingScope()) { Assert.That(TestableClientTransaction.IsInvalid(_invalidObject.ID), Is.True); Assert.That(subTransaction.IsInvalid(_invalidObject.ID), Is.True); ResurrectionService.ResurrectInvalidObject(TestableClientTransaction, _invalidObject.ID); Assert.That(TestableClientTransaction.IsInvalid(_invalidObject.ID), Is.False); Assert.That(subTransaction.IsInvalid(_invalidObject.ID), Is.False); } }
public void ResurrectObject_ViaSubTransaction() { var notFoundID = new ObjectID(typeof(Order), Guid.NewGuid()); var notFoundObject = LifetimeService.GetObjectReference(TestableClientTransaction, notFoundID); var subTransaction = TestableClientTransaction.CreateSubTransaction(); using (subTransaction.EnterDiscardingScope()) { notFoundObject.TryEnsureDataAvailable(); CheckStateIsInvalid(notFoundObject, TestableClientTransaction); CheckStateIsInvalid(notFoundObject, subTransaction); ResurrectionService.ResurrectInvalidObject(subTransaction, notFoundID); CheckStateIsNotInvalid(notFoundObject, TestableClientTransaction, StateType.NotLoadedYet); CheckStateIsNotInvalid(notFoundObject, subTransaction, StateType.NotLoadedYet); } }
public void NotInvalidAtAll() { var notInvalidObject = DomainObjectIDs.Order1.GetObject <Order> (); var subTransaction = TestableClientTransaction.CreateSubTransaction(); using (subTransaction.EnterDiscardingScope()) { CheckStateIsNotInvalid(notInvalidObject, TestableClientTransaction, StateType.Unchanged); CheckStateIsNotInvalid(notInvalidObject, subTransaction, StateType.NotLoadedYet); Assert.That( () => ResurrectionService.ResurrectInvalidObject(TestableClientTransaction, notInvalidObject.ID), Throws.InvalidOperationException.With.Message.EqualTo( "Cannot resurrect object '" + notInvalidObject.ID + "' because it is not invalid within the whole transaction hierarchy. " + "In transaction '" + subTransaction + "', the object has state 'NotLoadedYet'.")); var result = ResurrectionService.TryResurrectInvalidObject(TestableClientTransaction, notInvalidObject.ID); Assert.That(result, Is.False); } }
public void NewInDescendant() { var subTransaction = TestableClientTransaction.CreateSubTransaction(); using (subTransaction.EnterDiscardingScope()) { var newObject = Order.NewObject(); CheckStateIsInvalid(newObject, TestableClientTransaction); CheckStateIsNotInvalid(newObject, subTransaction, StateType.New); Assert.That( () => ResurrectionService.ResurrectInvalidObject(TestableClientTransaction, newObject.ID), Throws.InvalidOperationException.With.Message.EqualTo( "Cannot resurrect object '" + newObject.ID + "' because it is not invalid within the whole transaction hierarchy. " + "In transaction '" + subTransaction + "', the object has state 'New'.")); var result = ResurrectionService.TryResurrectInvalidObject(TestableClientTransaction, newObject.ID); Assert.That(result, Is.False); } }
public void ResurrectInvalidObject_Hierarchy_InvalidInRootOnly() { var subTransaction = TestableClientTransaction.CreateSubTransaction(); using (subTransaction.EnterDiscardingScope()) { var objectInvalidInRootOnly = Order.NewObject(); Assert.That(TestableClientTransaction.IsInvalid(objectInvalidInRootOnly.ID), Is.True); Assert.That(subTransaction.IsInvalid(objectInvalidInRootOnly.ID), Is.False); Assert.That( () => ResurrectionService.ResurrectInvalidObject(TestableClientTransaction, objectInvalidInRootOnly.ID), Throws.InvalidOperationException.With.Message.EqualTo( "Cannot resurrect object '" + objectInvalidInRootOnly.ID + "' because it is not invalid within the whole transaction hierarchy. " + "In transaction '" + subTransaction + "', the object has state 'New'.")); Assert.That(TestableClientTransaction.IsInvalid(objectInvalidInRootOnly.ID), Is.True); Assert.That(subTransaction.IsInvalid(objectInvalidInRootOnly.ID), Is.False); } }
private DataContainer GetTargetDataContainer(TransportItem transportItem, Dictionary <ObjectID, DomainObject> existingObjects, ClientTransaction bindingTargetTransaction) { DomainObject existingObject; if (existingObjects.TryGetValue(transportItem.ID, out existingObject)) { return(bindingTargetTransaction.DataManager.GetDataContainerWithLazyLoad(existingObject.ID, throwOnNotFound: true)); } else { var id = transportItem.ID; var instance = bindingTargetTransaction.GetInvalidObjectReference(id); ResurrectionService.ResurrectInvalidObject(bindingTargetTransaction, id); var newDataContainer = DataContainer.CreateNew(id); newDataContainer.SetDomainObject(instance); bindingTargetTransaction.DataManager.RegisterDataContainer(newDataContainer); return(newDataContainer); } }