示例#1
0
        public void CreateUnregisterCommandForDataContainer_New_IncludesRealObjectEndPoints_IncludesVirtualEndPoints()
        {
            var realEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "Customer");
            var dataContainer  = RelationEndPointTestHelper.CreateNewDataContainer(realEndPointID);

            _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer);
            var realEndPoint = _relationEndPointManager.RelationEndPoints[realEndPointID];

            var virtualObjectEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems");
            var virtualObjectEndPoint   = _relationEndPointManager.RelationEndPoints[virtualObjectEndPointID];

            Assert.That(virtualObjectEndPoint, Is.Not.Null);

            var collectionEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket");
            var collectionEndPoint   = _relationEndPointManager.RelationEndPoints[collectionEndPointID];

            Assert.That(collectionEndPoint, Is.Not.Null);

            var command = _relationEndPointManager.CreateUnregisterCommandForDataContainer(dataContainer);

            Assert.That(command, Is.TypeOf <UnregisterEndPointsCommand> ());
            Assert.That(((UnregisterEndPointsCommand)command).RegistrationAgent, Is.SameAs(_relationEndPointManager.RegistrationAgent));
            Assert.That(((UnregisterEndPointsCommand)command).Map, Is.SameAs(_relationEndPointManager.RelationEndPoints));
            Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.Member(realEndPoint));
            Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.Member(virtualObjectEndPoint));
            Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.Member(collectionEndPoint));
        }
示例#2
0
        public void SetDataFromSubTransaction_InvalidDefinition()
        {
            var otherID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems");
            var source  = RelationEndPointObjectMother.CreateCollectionEndPoint(otherID, new DomainObject[0]);

            _endPoint.SetDataFromSubTransaction(source);
        }
示例#3
0
        public void GetEndPointWithOppositeDefinition_ID_InvalidType()
        {
            var id       = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order).FullName + ".Customer");
            var endPoint = RelationEndPointObjectMother.CreateObjectEndPoint(id, null);

            endPoint.GetEndPointWithOppositeDefinition <IObjectEndPoint> ((ObjectID)null);
        }
示例#4
0
        public void SetDataFromSubTransaction_InvalidDefinition()
        {
            var            otherID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order");
            ObjectEndPoint source  = RelationEndPointObjectMother.CreateRealObjectEndPoint(otherID);

            _endPointPartialMock.SetDataFromSubTransaction(source);
        }
示例#5
0
        public void Initialize_InvalidDataContainer()
        {
            var id = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order");
            var foreignKeyDataContainer = DataContainer.CreateNew(DomainObjectIDs.Order1);

            Dev.Null = new RealObjectEndPoint(TestableClientTransaction, id, foreignKeyDataContainer, _endPointProviderStub, _transactionEventSinkStub);
        }
示例#6
0
        public void CreateUnregisterCommandForDataContainer_Existing_IncludesRealObjectEndPoints_IgnoresVirtualEndPoints()
        {
            var realEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "Customer");
            var dataContainer  = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(realEndPointID, DomainObjectIDs.Order3);

            _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer);
            var realEndPoint = _relationEndPointManager.RelationEndPoints[realEndPointID];

            var virtualObjectEndPointID   = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems");
            var virtualObjectEndPointStub = MockRepository.GenerateStub <IVirtualObjectEndPoint> ();

            virtualObjectEndPointStub.Stub(stub => stub.ID).Return(virtualObjectEndPointID);
            RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, virtualObjectEndPointStub);

            var collectionEndPointID   = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket");
            var collectionEndPointStub = MockRepository.GenerateStub <ICollectionEndPoint> ();

            collectionEndPointStub.Stub(stub => stub.ID).Return(collectionEndPointID);
            RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, collectionEndPointStub);

            var command = _relationEndPointManager.CreateUnregisterCommandForDataContainer(dataContainer);

            Assert.That(command, Is.TypeOf <UnregisterEndPointsCommand> ());
            Assert.That(((UnregisterEndPointsCommand)command).RegistrationAgent, Is.SameAs(_relationEndPointManager.RegistrationAgent));
            Assert.That(((UnregisterEndPointsCommand)command).Map, Is.SameAs(_relationEndPointManager.RelationEndPoints));
            Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.Member(realEndPoint));
            Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.No.Member(virtualObjectEndPointStub));
            Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.No.Member(collectionEndPointStub));
        }
示例#7
0
        public void CreateCollectionEndPoint_AnonymousEndPoint()
        {
            var endPointID = RelationEndPointObjectMother.CreateAnonymousEndPointID();

            Assert.That(
                () => _factory.CreateCollectionEndPoint(endPointID),
                Throws.ArgumentException.With.Message.EqualTo("End point ID must not refer to an anonymous end point.\r\nParameter name: id"));
        }
示例#8
0
        public void GetOppositeRelationEndPointIDs_BidirectionalEndPoint()
        {
            _endPointPartialMock.Stub(stub => stub.OppositeObjectID).Return(DomainObjectIDs.OrderTicket1);
            var oppositeEndPointIDs = _endPointPartialMock.GetOppositeRelationEndPointIDs().ToArray();

            var expectedID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order");

            Assert.That(oppositeEndPointIDs, Is.EqualTo(new[] { expectedID }));
        }
示例#9
0
        public void RegisterEndPointsForDataContainer_Existing_RegistersNoVirtualObjectEndPoints()
        {
            var endPointID    = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket");
            var dataContainer = RelationEndPointTestHelper.CreateExistingDataContainer(endPointID);

            _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer);

            Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.Null);
        }
        public override void SetUp()
        {
            base.SetUp();

            _eventSinkWithWock = MockRepository.GenerateMock <IClientTransactionEventSink>();
            _endPointID        = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems");

            _stateUpdateListener = new VirtualEndPointStateUpdateListener(_eventSinkWithWock);
        }
示例#11
0
        public void GetOppositeRelationEndPointID_NonNullEndPoint()
        {
            _endPointPartialMock.Stub(stub => stub.OppositeObjectID).Return(DomainObjectIDs.OrderTicket1);

            var oppositeEndPointID = _endPointPartialMock.GetOppositeRelationEndPointID();

            var expectedID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order");

            Assert.That(oppositeEndPointID, Is.EqualTo(expectedID));
        }
示例#12
0
        public void GetOppositeRelationEndPointIDs_UnidirectionalEndPoint()
        {
            var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Location1, "Client");
            var endPoint   = RelationEndPointObjectMother.CreateRealObjectEndPoint(endPointID);

            Assert.That(endPoint.Definition.GetOppositeEndPointDefinition().IsAnonymous, Is.True);

            var oppositeEndPointIDs = endPoint.GetOppositeRelationEndPointIDs().ToArray();

            Assert.That(oppositeEndPointIDs, Is.Empty);
        }
示例#13
0
        public void RegisterEndPointsForDataContainer_New_RegistersRealObjectEndPoints()
        {
            var endPointID         = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order");
            var dataContainer      = RelationEndPointTestHelper.CreateNewDataContainer(endPointID);
            var foreignKeyProperty = GetPropertyDefinition(typeof(OrderTicket), "Order");

            _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer);

            var objectEndPoint = (RealObjectEndPoint)_relationEndPointManager.RelationEndPoints[endPointID];

            Assert.That(objectEndPoint.PropertyDefinition, Is.EqualTo(foreignKeyProperty));
        }
        public void SetOppositeObjectDataFromSubTransaction()
        {
            var source = RelationEndPointObjectMother.CreateVirtualObjectEndPoint(_endPointID, TestableClientTransaction);

            _loadStateMock.Expect(mock => mock.SetDataFromSubTransaction(_endPoint, VirtualObjectEndPointTestHelper.GetLoadState(source)));
            _loadStateMock.Stub(mock => mock.HasChanged()).Return(true);
            _loadStateMock.Replay();

            PrivateInvoke.InvokeNonPublicMethod(_endPoint, "SetOppositeObjectDataFromSubTransaction", source);

            _loadStateMock.VerifyAllExpectations();
        }
示例#15
0
        public void GetEndPointWithOppositeDefinition_ID()
        {
            var id       = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order).FullName + ".Customer");
            var endPoint = RelationEndPointObjectMother.CreateObjectEndPoint(id, null);

            var customer         = DomainObjectIDs.Customer1.GetObject <Customer> ();
            var oppositeEndPoint = endPoint.GetEndPointWithOppositeDefinition <ICollectionEndPoint> (customer.ID);

            var oppositeID = RelationEndPointID.Create(customer.ID, endPoint.Definition.GetOppositeEndPointDefinition());

            Assert.That(oppositeEndPoint, Is.SameAs(TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading(oppositeID)));
        }
示例#16
0
        public void GetEndPointWithOppositeDefinition_ID_Null()
        {
            var id       = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order).FullName + ".Customer");
            var endPoint = RelationEndPointObjectMother.CreateObjectEndPoint(id, null);

            var oppositeEndPoint = endPoint.GetEndPointWithOppositeDefinition <ICollectionEndPoint> ((ObjectID)null);

            Assert.That(oppositeEndPoint, Is.InstanceOf(typeof(NullCollectionEndPoint)));
            var expectedID = RelationEndPointID.Create(null, endPoint.Definition.GetOppositeEndPointDefinition());

            Assert.That(oppositeEndPoint.ID, Is.EqualTo(expectedID));
        }
示例#17
0
        public void RegisterEndPointsForDataContainer_Existing_RegistersNoOppositeNullObjectEndPoints()
        {
            var endPointID    = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order");
            var dataContainer = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(endPointID, null);

            _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer);

            var oppositeEndPointDefinition = endPointID.Definition.GetOppositeEndPointDefinition();
            var expectedID = RelationEndPointID.Create(null, oppositeEndPointDefinition);

            Assert.That(_relationEndPointManager.RelationEndPoints[expectedID], Is.Null);
        }
示例#18
0
        public void GetOrCreateVirtualEndPoint_NewlyCreated_CollectionEndPoint()
        {
            var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems");

            Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.Null);

            var result = _relationEndPointManager.GetOrCreateVirtualEndPoint(endPointID);

            Assert.That(result, Is.Not.Null.And.AssignableTo <ICollectionEndPoint>());
            Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.SameAs(result));
            Assert.That(result.IsDataComplete, Is.False);
        }
示例#19
0
        public void RegisterEndPointsForDataContainer_New_RegistersCollectionEndPoints()
        {
            var endPointID    = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems");
            var dataContainer = RelationEndPointTestHelper.CreateNewDataContainer(endPointID);

            _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer);

            var collectionEndPoint = (ICollectionEndPoint)_relationEndPointManager.RelationEndPoints[endPointID];

            Assert.That(collectionEndPoint, Is.Not.Null);
            Assert.That(collectionEndPoint.IsDataComplete, Is.True);
            Assert.That(collectionEndPoint.Collection, Is.Empty);
        }
示例#20
0
        public void RegisterEndPointsForDataContainer_New_RegistersVirtualObjectEndPoints()
        {
            var endPointID    = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket");
            var dataContainer = RelationEndPointTestHelper.CreateNewDataContainer(endPointID);

            _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer);

            var objectEndPoint = (IVirtualObjectEndPoint)_relationEndPointManager.RelationEndPoints[endPointID];

            Assert.That(objectEndPoint, Is.Not.Null);
            Assert.That(objectEndPoint.IsDataComplete, Is.True);
            Assert.That(objectEndPoint.OppositeObjectID, Is.Null);
        }
示例#21
0
        public void GetRelationEndPointWithLazyLoad_LoadsData_OfObjectsWithRealEndPointNotYetRegistered()
        {
            var locationEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Location1, "Client");

            Assert.That(locationEndPointID.Definition.IsVirtual, Is.False);
            Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Location1], Is.Null);

            var result = _relationEndPointManager.GetRelationEndPointWithLazyLoad(locationEndPointID);

            Assert.That(result, Is.Not.Null);

            Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Location1], Is.Not.Null);
        }
示例#22
0
        public void Initialize_WithAnonymousEndPointID_Throws()
        {
            var endPointID = RelationEndPointObjectMother.CreateAnonymousEndPointID();

            new CollectionEndPoint(
                TestableClientTransaction,
                endPointID,
                _collectionManagerMock,
                _lazyLoaderMock,
                _endPointProviderStub,
                _transactionEventSinkStub,
                _dataManagerFactoryStub);
        }
示例#23
0
        public void GetRelationEndPointWithLazyLoad_DoesNotLoadData_OfObjectsWithVirtualEndPointNotYetRegistered()
        {
            var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket");

            Assert.That(endPointID.Definition.IsVirtual, Is.True);
            Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Order1], Is.Null);

            var result = _relationEndPointManager.GetRelationEndPointWithLazyLoad(endPointID);

            Assert.That(result, Is.Not.Null);

            Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Order1], Is.Null);
        }
示例#24
0
        public void RegisterEndPointsForDataContainer_Existing_RegistersOppositeVirtualObjectEndPoints()
        {
            var endPointID    = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order");
            var dataContainer = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(endPointID, DomainObjectIDs.Order3);

            _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer);

            var oppositeID       = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order3, "OrderTicket");
            var oppositeEndPoint = (IVirtualObjectEndPoint)_relationEndPointManager.RelationEndPoints[oppositeID];

            Assert.That(oppositeEndPoint, Is.Not.Null);
            Assert.That(oppositeEndPoint.OppositeObjectID, Is.EqualTo(DomainObjectIDs.OrderTicket1));
        }
        public void GetAllRelationEndPointIDs()
        {
            var endPointIDs = RelationEndPointID.GetAllRelationEndPointIDs(DomainObjectIDs.Order1);

            var expectedIDs = new[]
            {
                RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "Customer"),
                RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"),
                RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems"),
                RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "Official"),
            };

            Assert.That(endPointIDs, Is.EquivalentTo(expectedIDs));
        }
示例#26
0
        public void GetRelationEndPointWithLazyLoad_RegistersVirtualObjectEndPointWithNull()
        {
            _relationEndPointManager.ClientTransaction.EnsureDataAvailable(DomainObjectIDs.Employee1); // preload Employee before lazily loading its virtual end point

            var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Employee1, "Computer");

            Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.Null);

            var endPoint = _relationEndPointManager.GetRelationEndPointWithLazyLoad(endPointID);

            Assert.That(endPoint, Is.Not.Null);
            Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.SameAs(endPoint));
            Assert.That(((IVirtualObjectEndPoint)endPoint).OppositeObjectID, Is.Null);
        }
示例#27
0
        public override void SetUp()
        {
            base.SetUp();

            _endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order");
            _foreignKeyDataContainer  = DataContainer.CreateForExisting(_endPointID.ObjectID, null, pd => pd.DefaultValue);
            _endPointProviderStub     = MockRepository.GenerateStub <IRelationEndPointProvider>();
            _transactionEventSinkStub = MockRepository.GenerateStub <IClientTransactionEventSink>();
            _syncStateMock            = MockRepository.GenerateStrictMock <IRealObjectEndPointSyncState> ();

            _endPoint = new RealObjectEndPoint(
                TestableClientTransaction, _endPointID, _foreignKeyDataContainer, _endPointProviderStub, _transactionEventSinkStub);
            PrivateInvoke.SetNonPublicField(_endPoint, "_syncState", _syncStateMock);
        }
示例#28
0
        public void RegisterEndPointsForDataContainer_Existing_RegistersRealObjectEndPoints()
        {
            var endPointID         = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order");
            var dataContainer      = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(endPointID, DomainObjectIDs.Order3);
            var foreignKeyProperty = GetPropertyDefinition(typeof(OrderTicket), "Order");

            _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer);

            var endPoint = (RealObjectEndPoint)_relationEndPointManager.RelationEndPoints[endPointID];

            Assert.That(endPoint, Is.Not.Null);
            Assert.That(endPoint.PropertyDefinition, Is.EqualTo(foreignKeyProperty));
            Assert.That(endPoint.OppositeObjectID, Is.EqualTo(DomainObjectIDs.Order3));
        }
示例#29
0
        public void Reset_RaisesUnregisteringEvents()
        {
            var endPointID   = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Customer1, "Orders");
            var endPointStub = MockRepository.GenerateStub <IRelationEndPoint> ();

            endPointStub.Stub(stub => stub.ID).Return(endPointID);
            RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointStub);

            var listenerMock = ClientTransactionTestHelperWithMocks.CreateAndAddListenerMock(_relationEndPointManager.ClientTransaction);

            _relationEndPointManager.Reset();

            listenerMock.AssertWasCalled(mock => mock.RelationEndPointMapUnregistering(_relationEndPointManager.ClientTransaction, endPointID));
        }
示例#30
0
        public void SetDataFromSubTransaction()
        {
            var source = RelationEndPointObjectMother.CreateCollectionEndPoint(_customerEndPointID, new[] { _order3 });

            _loadStateMock.Stub(stub => stub.HasChanged()).Return(false);
            _loadStateMock.Expect(mock => mock.SetDataFromSubTransaction(_endPoint, CollectionEndPointTestHelper.GetLoadState(source)));
            _loadStateMock.Replay();

            _collectionManagerMock.Stub(stub => stub.HasCollectionReferenceChanged()).Return(false);

            _endPoint.SetDataFromSubTransaction(source);

            _loadStateMock.VerifyAllExpectations();
        }