public void CollectionEndPoint_DelegatingDataMembers() { _endPoint.Collection.Add(DomainObjectIDs.OrderItem5.GetObject <OrderItem>()); var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint); DomainObjectCollectionDataTestHelper.CheckAssociatedCollectionStrategy( deserializedEndPoint.Collection, _endPoint.Collection.RequiredItemType, deserializedEndPoint.ID); }
public void SetCollection_DataStrategy_OfNewOpposites() { var newOpposites = new OrderCollection { _order2 }; SetCollectionAndNotify(_customerEndPoint, newOpposites); // New collection now has a delegating data store... DomainObjectCollectionDataTestHelper.CheckAssociatedCollectionStrategy(newOpposites, typeof(Order), _customerEndPoint.ID); // ... and the end-point now has data newOpposites had before! Assert.That(_customerEndPoint.GetData(), Is.EqualTo(new[] { _order2 })); Assert.That(newOpposites, Is.EqualTo(new[] { _order2 })); }
public void TransformToAssociated() { var endPointID = RelationEndPointID.Create(DomainObjectIDs.Customer1, typeof(Customer), "Orders"); var originalCollectionDataStrategy = DomainObjectCollectionDataTestHelper.GetDataStrategy(_collection); var originalCollectionContents = _collection.Cast <DomainObject> ().ToArray(); var originalEndPointContents = ((ICollectionEndPoint)TestableClientTransaction.DataManager.GetRelationEndPointWithLazyLoad(endPointID)).GetData().ToArray(); var associatedCollectionDataStrategyFactory = new AssociatedCollectionDataStrategyFactory(TestableClientTransaction.DataManager); var result = ((IAssociatableDomainObjectCollection)_collection).TransformToAssociated(endPointID, associatedCollectionDataStrategyFactory); DomainObjectCollectionDataTestHelper.CheckAssociatedCollectionStrategy(_collection, typeof(Order), endPointID); Assert.That(result, Is.SameAs(originalCollectionDataStrategy)); Assert.That(result, Is.EqualTo(originalCollectionContents)); Assert.That(_collection, Is.EqualTo(originalEndPointContents)); }
public void Commit_AfterReplace_DelegationChain() { var oldCollection = _customerEndPoint.Collection; var newCollection = new OrderCollection { _order3 }; SetCollectionAndNotify(_customerEndPoint, newCollection); Assert.That(_customerEndPoint.Collection, Is.SameAs(newCollection)); Assert.That(newCollection.AssociatedEndPointID, Is.EqualTo(_customerEndPoint.ID)); Assert.That(oldCollection.AssociatedEndPointID, Is.Null); _customerEndPoint.Commit(); DomainObjectCollectionDataTestHelper.CheckStandAloneCollectionStrategy(oldCollection, typeof(Order)); DomainObjectCollectionDataTestHelper.CheckAssociatedCollectionStrategy(newCollection, typeof(Order), _customerEndPoint.ID); }