Esempio n. 1
0
        public void IsSynchronized_AnonymousRelationEndPoint()
        {
            var locationClientEndPoint = RelationEndPointID.Create(DomainObjectIDs.Location1, typeof(Location), "Client");
            var oppositeEndPoint       = RelationEndPointID.Create(DomainObjectIDs.Client1, locationClientEndPoint.Definition.GetOppositeEndPointDefinition());

            BidirectionalRelationSyncService.IsSynchronized(_transaction, oppositeEndPoint);
        }
Esempio n. 2
0
        public void EagerFetching_UsesForeignKeyDataFromDatabase_NotTransaction()
        {
            // This will retrieve Order1.
            var ordersQuery = CreateOrdersQuery("OrderNo = 1");

            // This will fetch OrderItem1 and OrderItem2, both pointing to Order1.
            AddOrderItemsFetchQuery(ordersQuery, "o.OrderNo = 1");

            // Fake OrderItem2 to point to Order3 in memory.
            var orderItem2 = RegisterFakeOrderItem(DomainObjectIDs.OrderItem2, DomainObjectIDs.Order3);

            var result = TestableClientTransaction.QueryManager.GetCollection(ordersQuery);

            var order1 = DomainObjectIDs.Order1.GetObject <Order> ();

            Assert.That(result.ToArray(), Is.EquivalentTo(new[] { order1 }));

            var orderItemsEndPointID = RelationEndPointID.Resolve(order1, o => o.OrderItems);
            var orderItemsEndPoint   = TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading(orderItemsEndPointID);

            Assert.That(orderItemsEndPoint, Is.Not.Null);
            Assert.That(orderItemsEndPoint.IsDataComplete, Is.True);

            // The relation contains the fetched result, disregarding the in-memory data. This makes it an unsynchronized relation.
            Assert.That(
                order1.OrderItems,
                Is.EquivalentTo(new[] { DomainObjectIDs.OrderItem1.GetObject <OrderItem>(), orderItem2 }));

            Assert.That(orderItem2.Order, Is.Not.SameAs(order1));
            Assert.That(BidirectionalRelationSyncService.IsSynchronized(TestableClientTransaction, orderItemsEndPointID), Is.False);
        }
Esempio n. 3
0
 protected void CheckSyncState <TOriginating, TRelated> (
     TOriginating originating,
     Expression <Func <TOriginating, TRelated> > propertyAccessExpression,
     bool expectedState)
     where TOriginating : DomainObject
 {
     Assert.That(
         BidirectionalRelationSyncService.IsSynchronized(ClientTransaction.Current, RelationEndPointID.Resolve(originating, propertyAccessExpression)),
         Is.EqualTo(expectedState));
 }
Esempio n. 4
0
        public void IsSynchronized_EndPointReturnsNull()
        {
            var endPointID   = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderItems");
            var endPointStub = MockRepository.GenerateStub <IRelationEndPoint> ();

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

            var result = BidirectionalRelationSyncService.IsSynchronized(_transaction, endPointID);

            Assert.That(result, Is.Null);
        }
Esempio n. 5
0
        public void IsSynchronized()
        {
            var endPointID   = RelationEndPointID.Create(DomainObjectIDs.OrderItem1, typeof(OrderItem), "Order");
            var endPointStub = MockRepository.GenerateStub <IRelationEndPoint>();

            endPointStub.Stub(stub => stub.ID).Return(endPointID);
            endPointStub.Stub(stub => stub.Definition).Return(endPointID.Definition);
            endPointStub.Stub(stub => stub.IsDataComplete).Return(true);
            endPointStub.Stub(stub => stub.IsSynchronized).Return(true).Repeat.Once();
            endPointStub.Stub(stub => stub.IsSynchronized).Return(false).Repeat.Once();
            RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointStub);

            Assert.That(BidirectionalRelationSyncService.IsSynchronized(_transaction, endPointID), Is.True);
            Assert.That(BidirectionalRelationSyncService.IsSynchronized(_transaction, endPointID), Is.False);
        }
Esempio n. 6
0
        public void IsSynchronized_EndPointNotRegistered()
        {
            var result = BidirectionalRelationSyncService.IsSynchronized(_transaction, RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderTicket"));

            Assert.That(result, Is.Null);
        }
Esempio n. 7
0
 public void IsSynchronized_UnidirectionalRelationEndPoint()
 {
     BidirectionalRelationSyncService.IsSynchronized(_transaction, RelationEndPointID.Create(DomainObjectIDs.Location1, typeof(Location), "Client"));
 }