public void TryResurrectInvalidObject() { Assert.That(TestableClientTransaction.IsInvalid(_invalidObject.ID), Is.True); var result = ResurrectionService.TryResurrectInvalidObject(TestableClientTransaction, _invalidObject.ID); Assert.That(result, Is.True); Assert.That(TestableClientTransaction.IsInvalid(_invalidObject.ID), Is.False); }
public void DiscardedNewObject_TryResurrect() { var newObject = Order.NewObject(); newObject.Delete(); CheckStateIsInvalid(newObject, TestableClientTransaction); var result = ResurrectionService.TryResurrectInvalidObject(TestableClientTransaction, newObject.ID); Assert.That(result, Is.True); CheckStateIsNotInvalid(newObject, TestableClientTransaction, StateType.NotLoadedYet); }
public void NotFoundObject_TryResurrect() { var notFoundID = new ObjectID(typeof(Order), Guid.NewGuid()); var notFoundObject = LifetimeService.GetObjectReference(TestableClientTransaction, notFoundID); notFoundObject.TryEnsureDataAvailable(); CheckStateIsInvalid(notFoundObject, TestableClientTransaction); var result = ResurrectionService.TryResurrectInvalidObject(TestableClientTransaction, notFoundID); Assert.That(result, Is.True); CheckStateIsNotInvalid(notFoundObject, TestableClientTransaction, StateType.NotLoadedYet); }
public void DiscardedDeletedObject_TryResurrect() { SetDatabaseModifyable(); var deletedObject = DomainObjectIDs.ClassWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); deletedObject.Delete(); TestableClientTransaction.Commit(); CheckStateIsInvalid(deletedObject, TestableClientTransaction); var result = ResurrectionService.TryResurrectInvalidObject(TestableClientTransaction, deletedObject.ID); Assert.That(result, Is.True); CheckStateIsNotInvalid(deletedObject, TestableClientTransaction, StateType.NotLoadedYet); }
public void TryResurrectInvalidObject_Hierarchy() { var subTransaction = TestableClientTransaction.CreateSubTransaction(); using (subTransaction.EnterDiscardingScope()) { Assert.That(TestableClientTransaction.IsInvalid(_invalidObject.ID), Is.True); Assert.That(subTransaction.IsInvalid(_invalidObject.ID), Is.True); var result = ResurrectionService.TryResurrectInvalidObject(TestableClientTransaction, _invalidObject.ID); Assert.That(result, Is.True); Assert.That(TestableClientTransaction.IsInvalid(_invalidObject.ID), Is.False); Assert.That(subTransaction.IsInvalid(_invalidObject.ID), Is.False); } }
public void TryResurrectInvalidObject_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); var result = ResurrectionService.TryResurrectInvalidObject(TestableClientTransaction, objectInvalidInRootOnly.ID); Assert.That(result, Is.False); Assert.That(TestableClientTransaction.IsInvalid(objectInvalidInRootOnly.ID), Is.True); Assert.That(subTransaction.IsInvalid(objectInvalidInRootOnly.ID), Is.False); } }
public void TryResurrectInvalidObject_Hierarchy_InvalidInSubOnly() { var objectInvalidInSubOnly = DomainObjectIDs.Order1.GetObject <Order> (); objectInvalidInSubOnly.Delete(); var subTransaction = TestableClientTransaction.CreateSubTransaction(); using (subTransaction.EnterDiscardingScope()) { Assert.That(TestableClientTransaction.IsInvalid(objectInvalidInSubOnly.ID), Is.False); Assert.That(subTransaction.IsInvalid(objectInvalidInSubOnly.ID), Is.True); var result = ResurrectionService.TryResurrectInvalidObject(TestableClientTransaction, objectInvalidInSubOnly.ID); Assert.That(result, Is.False); Assert.That(TestableClientTransaction.IsInvalid(objectInvalidInSubOnly.ID), Is.False); Assert.That(subTransaction.IsInvalid(objectInvalidInSubOnly.ID), Is.True); } }
public void TryResurrectObject_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); var result = ResurrectionService.TryResurrectInvalidObject(subTransaction, notFoundID); Assert.That(result, Is.True); 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); } }