public void MarkDataComplete() { Action <ICollectionEndPointDataManager> stateSetter = null; var items = new DomainObject[0]; _loadStateMock .Expect(mock => mock.MarkDataComplete(Arg.Is(_endPoint), Arg.Is(items), Arg <Action <ICollectionEndPointDataManager> > .Is.Anything)) .WhenCalled(mi => { stateSetter = (Action <ICollectionEndPointDataManager>)mi.Arguments[2]; }); _loadStateMock.Replay(); _endPoint.MarkDataComplete(items); _loadStateMock.VerifyAllExpectations(); Assert.That(CollectionEndPointTestHelper.GetLoadState(_endPoint), Is.SameAs(_loadStateMock)); var dataManagerStub = MockRepository.GenerateStub <ICollectionEndPointDataManager>(); stateSetter(dataManagerStub); var newLoadState = CollectionEndPointTestHelper.GetLoadState(_endPoint); Assert.That(newLoadState, Is.TypeOf(typeof(CompleteCollectionEndPointLoadState))); Assert.That(((CompleteCollectionEndPointLoadState)newLoadState).DataManager, Is.SameAs(dataManagerStub)); Assert.That(((CompleteCollectionEndPointLoadState)newLoadState).TransactionEventSink, Is.SameAs(_transactionEventSinkStub)); Assert.That(((CompleteCollectionEndPointLoadState)newLoadState).EndPointProvider, Is.SameAs(_endPointProviderStub)); }
public static void FillCollectionEndPointWithInitialContents(CollectionEndPoint endPoint, IEnumerable <DomainObject> initialContents) { var dataManager = ClientTransactionTestHelper.GetDataManager(endPoint.ClientTransaction); var domainObjects = initialContents.ToArray(); foreach (var domainObject in domainObjects) { var oppositeEndPointID = RelationEndPointID.Create(domainObject.ID, endPoint.Definition.GetOppositeEndPointDefinition()); var oppositeEndPoint = (IRealObjectEndPoint)dataManager.GetRelationEndPointWithLazyLoad(oppositeEndPointID); endPoint.RegisterOriginalOppositeEndPoint(oppositeEndPoint); } endPoint.MarkDataComplete(domainObjects); }