public void DeleteObject_Twice() { Order order = DomainObjectIDs.Order1.GetObject <Order> (); LifetimeService.DeleteObject(TestableClientTransaction, order); LifetimeService.DeleteObject(TestableClientTransaction, order); }
public override void SetUp() { base.SetUp(); _invalidObject = Order.NewObject(); LifetimeService.DeleteObject(TestableClientTransaction, _invalidObject); }
public static DomainObject GetInvalidObject(ClientTransaction transaction) { var invalidInstance = LifetimeService.NewObject(transaction, typeof(Order), ParamList.Empty); LifetimeService.DeleteObject(transaction, invalidInstance); Assert.That(invalidInstance.TransactionContext[transaction].State, Is.EqualTo(StateType.Invalid)); return(invalidInstance); }
public static DomainObject GetDeletedObject(ClientTransaction transaction, ObjectID objectID) { var deletedInstance = LifetimeService.GetObjectReference(transaction, objectID); LifetimeService.DeleteObject(transaction, deletedInstance); Assert.That(deletedInstance.TransactionContext[transaction].State, Is.EqualTo(StateType.Deleted)); return(deletedInstance); }
public void TryGetObject_Deleted() { var domainObject = LifetimeService.GetObject(TestableClientTransaction, DomainObjectIDs.ClassWithAllDataTypes1, false); LifetimeService.DeleteObject(TestableClientTransaction, domainObject); Assert.That(LifetimeService.TryGetObject(TestableClientTransaction, domainObject.ID), Is.SameAs(domainObject)); }
public void DeleteObject() { Order order = DomainObjectIDs.Order1.GetObject <Order> (); Assert.That(order.State, Is.Not.EqualTo(StateType.Deleted)); LifetimeService.DeleteObject(TestableClientTransaction, order); Assert.That(order.State, Is.EqualTo(StateType.Deleted)); }
public void GetState_Invalidated_AfterDiscard() { var stateBeforeChange = _cachingListener.GetState(_newOrder.ID); LifetimeService.DeleteObject(_transaction, _newOrder); var stateAfterChange = _cachingListener.GetState(_newOrder.ID); Assert.That(stateBeforeChange, Is.EqualTo(StateType.New)); Assert.That(stateAfterChange, Is.EqualTo(StateType.Invalid)); }
public void GetObject_Deleted() { var domainObject = LifetimeService.GetObject(TestableClientTransaction, DomainObjectIDs.ClassWithAllDataTypes1, false); LifetimeService.DeleteObject(TestableClientTransaction, domainObject); Assert.That( () => LifetimeService.GetObject(TestableClientTransaction, domainObject.ID, false), Throws.TypeOf <ObjectDeletedException> ().With.Message.EqualTo( "Object 'ClassWithAllDataTypes|3f647d79-0caf-4a53-baa7-a56831f8ce2d|System.Guid' is already deleted.")); Assert.That(LifetimeService.GetObject(TestableClientTransaction, domainObject.ID, true), Is.SameAs(domainObject)); }
public void CanRead_InvalidObject_ReturnsFalse() { var instance = SampleBindableDomainObject.NewObject(); var property = GetProperty(instance); var strategy = (IBindablePropertyReadAccessStrategy) new BindableDomainObjectPropertyReadAccessStrategy(); LifetimeService.DeleteObject(instance.DefaultTransactionContext.ClientTransaction, instance); Assert.That(instance.State, Is.EqualTo(StateType.Invalid)); var result = strategy.CanRead(instance, property); Assert.That(result, Is.False); }
public void IsDefaultDefault_StateIsNotNew() { var instance = SampleBindableDomainObject.NewObject(); LifetimeService.DeleteObject(instance.DefaultTransactionContext.ClientTransaction, instance); var property = GetProperty(instance); var strategy = (IDefaultValueStrategy) new BindableDomainObjectDefaultValueStrategy(); Assert.That(instance.State, Is.Not.EqualTo(StateType.New)); var result = strategy.IsDefaultValue(instance, property); Assert.That(result, Is.False); }
public void CanRead_DeletedObject_ReturnsFalse() { var instance = SampleBindableDomainObject.NewObject(); var property = GetProperty(instance); var strategy = (IBindablePropertyReadAccessStrategy) new BindableDomainObjectPropertyReadAccessStrategy(); using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope()) { LifetimeService.DeleteObject(instance.DefaultTransactionContext.ClientTransaction, instance); Assert.That(instance.State, Is.EqualTo(StateType.Deleted)); var result = strategy.CanRead(instance, property); Assert.That(result, Is.False); } }
private TransportedDomainObjects TransportAndDeleteObjects(params ObjectID[] objectsToLoadAndDelete) { var transporter = new DomainObjectTransporter(); foreach (ObjectID id in objectsToLoadAndDelete) { transporter.Load(id); } ModifyDatabase( delegate { foreach (var id in objectsToLoadAndDelete) { var domainObject = LifetimeService.GetObject(ClientTransaction.Current, id, false); LifetimeService.DeleteObject(ClientTransaction.Current, domainObject); } }); return(Transport(transporter)); }
/// <summary> /// Deletes the <see cref="DomainObject"/> in the default transaction, ie. in its binding transaction or - if /// none - <see cref="DomainObjects.ClientTransaction.Current"/>. /// </summary> /// <exception cref="ObjectInvalidException">The object is invalid in the transaction.</exception> /// <remarks>To perform custom actions when a <see cref="DomainObject"/> is deleted <see cref="OnDeleting"/> and <see cref="OnDeleted"/> should be overridden.</remarks> protected void Delete() { CheckInitializeEventNotExecuting(); LifetimeService.DeleteObject(DefaultTransactionContext.ClientTransaction, this); }
public void GetState_IsInvalid() { LifetimeService.DeleteObject(_transaction, _newOrder); Assert.That(_cachingListener.GetState(_newOrder.ID), Is.EqualTo(StateType.Invalid)); }