private void CheckOriginalDataMatches(IDomainObjectCollectionData expected, IDomainObjectCollectionData actual) { var expectedInner = DomainObjectCollectionDataTestHelper.GetWrappedDataAndCheckType <CopyOnWriteDomainObjectCollectionData> ( (ReadOnlyCollectionDataDecorator)expected); var actualInner = DomainObjectCollectionDataTestHelper.GetWrappedDataAndCheckType <CopyOnWriteDomainObjectCollectionData> ( (ReadOnlyCollectionDataDecorator)actual); Assert.That(actualInner, Is.SameAs(expectedInner)); }
private void CheckOriginalDataNotCopied(ChangeCachingCollectionDataDecorator decorator) { var originalData = DomainObjectCollectionDataTestHelper.GetWrappedDataAndCheckType <CopyOnWriteDomainObjectCollectionData> ( decorator.OriginalData); var originalDataStore = DomainObjectCollectionDataTestHelper.GetWrappedData(originalData); var observedWrappedData = PrivateInvoke.GetNonPublicField(decorator, "_observedWrappedData"); Assert.That(originalDataStore, Is.SameAs(observedWrappedData)); }
public void RegisterOriginalItem_ItemAlreadyExists_InOriginal() { var underlyingOriginalData = DomainObjectCollectionDataTestHelper.GetWrappedDataAndCheckType <CopyOnWriteDomainObjectCollectionData> ( _decoratorWithRealData.OriginalData); var domainObject = DomainObjectMother.CreateFakeObject <Order> (); underlyingOriginalData.Add(domainObject); Assert.That(_decoratorWithRealData.GetObject(domainObject.ID), Is.Null); Assert.That(_decoratorWithRealData.OriginalData.GetObject(domainObject.ID), Is.Not.Null); _decoratorWithRealData.RegisterOriginalItem(domainObject); }
public void CreateDataStrategyForEndPoint() { var ordersEndPointID = RelationEndPointID.Create(DomainObjectIDs.Customer1, typeof(Customer), "Orders"); var result = _factory.CreateDataStrategyForEndPoint(ordersEndPointID); Assert.That(result, Is.TypeOf <ModificationCheckingCollectionDataDecorator> ()); var checkingDecorator = (ModificationCheckingCollectionDataDecorator)result; Assert.That(checkingDecorator.RequiredItemType, Is.SameAs(typeof(Order))); var delegator = DomainObjectCollectionDataTestHelper.GetWrappedDataAndCheckType <EndPointDelegatingCollectionData> (checkingDecorator); Assert.That(delegator.AssociatedEndPointID, Is.EqualTo(ordersEndPointID)); Assert.That(delegator.VirtualEndPointProvider, Is.SameAs(_virtualEndPointProviderStub)); }
public void CreateDataStrategyForStandAloneCollection() { var dataStoreStub = MockRepository.GenerateStub <IDomainObjectCollectionData> (); var eventRaiserStub = MockRepository.GenerateStub <IDomainObjectCollectionEventRaiser> (); var modificationCheckingDecorator = DomainObjectCollection.CreateDataStrategyForStandAloneCollection(dataStoreStub, typeof(Order), eventRaiserStub); Assert.That(modificationCheckingDecorator, Is.InstanceOf(typeof(ModificationCheckingCollectionDataDecorator))); Assert.That(modificationCheckingDecorator.RequiredItemType, Is.SameAs(typeof(Order))); var eventRaisingDecorator = DomainObjectCollectionDataTestHelper.GetWrappedDataAndCheckType <EventRaisingCollectionDataDecorator> ( (ModificationCheckingCollectionDataDecorator)modificationCheckingDecorator); Assert.That(eventRaisingDecorator.EventRaiser, Is.SameAs(eventRaiserStub)); var dataStore = DomainObjectCollectionDataTestHelper.GetWrappedDataAndCheckType <IDomainObjectCollectionData> (eventRaisingDecorator); Assert.That(dataStore, Is.SameAs(dataStoreStub)); }
public void DomainObjectCollection_Associated() { var customer1 = DomainObjectIDs.Customer1.GetObject <Customer> (); var collection = customer1.Orders; var endPointID = collection.AssociatedEndPointID; var relatedIDs = collection.Select(obj => obj.ID).ToArray(); var deserializedCollectionAndTransaction = Serializer.SerializeAndDeserialize(Tuple.Create(collection, TestableClientTransaction)); var deserializedCollection = deserializedCollectionAndTransaction.Item1; var deserializedTransaction = deserializedCollectionAndTransaction.Item2; var deserializedEndPoint = deserializedTransaction.DataManager.GetRelationEndPointWithoutLoading(endPointID); Assert.That(DomainObjectCollectionDataTestHelper.GetAssociatedEndPoint(deserializedCollection), Is.SameAs(deserializedEndPoint)); var deserializedData = DomainObjectCollectionDataTestHelper.GetDataStrategyAndCheckType <ModificationCheckingCollectionDataDecorator> (deserializedCollection); DomainObjectCollectionDataTestHelper.GetWrappedDataAndCheckType <EndPointDelegatingCollectionData> (deserializedData); Assert.That(collection.Select(obj => obj.ID).ToArray(), Is.EqualTo(relatedIDs)); }
private void CallOnDataChangedOnWrappedData(ChangeCachingCollectionDataDecorator decorator) { var wrappedData = DomainObjectCollectionDataTestHelper.GetWrappedDataAndCheckType <ObservableCollectionDataDecorator> (decorator); PrivateInvoke.InvokeNonPublicMethod(wrappedData, "OnDataChanged", ObservableCollectionDataDecoratorBase.OperationKind.Remove, _domainObject, 12); }