Exemplo n.º 1
0
        public void CollectionItems_Unsynchronized_WithUnload()
        {
            SetDatabaseModifyable();

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

            order.OrderItems.EnsureDataComplete();

            var orderItemID = RelationInconcsistenciesTestHelper.CreateObjectAndSetRelationInOtherTransaction <OrderItem, Order> (order.ID, (oi, o) => oi.Order = o);
            var orderItem   = orderItemID.GetObject <OrderItem>();
            var endPointID  = RelationEndPointID.Resolve(orderItem, oi => oi.Order);
            var endPoint    = (RealObjectEndPoint)TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading(endPointID);

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

            Assert.That(RealObjectEndPointTestHelper.GetSyncState(endPoint), Is.TypeOf(typeof(UnsynchronizedRealObjectEndPointSyncState)));

            UnloadService.UnloadVirtualEndPoint(TestableClientTransaction, orderItem.Order.OrderItems.AssociatedEndPointID);

            Assert.That(RealObjectEndPointTestHelper.GetSyncState(endPoint), Is.TypeOf(typeof(UnknownRealObjectEndPointSyncState)));

            order.OrderItems.EnsureDataComplete();

            Assert.That(RealObjectEndPointTestHelper.GetSyncState(endPoint), Is.TypeOf(typeof(SynchronizedRealObjectEndPointSyncState)));
        }
        public void UnloadLastFK_CausesVirtualObjectEndPointToBeRemoved()
        {
            SetDatabaseModifyable();

            var employee          = DomainObjectIDs.Employee3.GetObject <Employee> ();
            var virtualEndPointID = RelationEndPointID.Resolve(employee, e => e.Computer);

            TestableClientTransaction.EnsureDataComplete(virtualEndPointID);

            var unsynchronizedComputerID =
                RelationInconcsistenciesTestHelper.CreateObjectAndSetRelationInOtherTransaction <Computer, Employee> (
                    employee.ID,
                    (c, e) => c.Employee = e);
            var unsynchronizedComputer = unsynchronizedComputerID.GetObject <Computer> ();

            Assert.That(_dataManager.GetRelationEndPointWithoutLoading(virtualEndPointID), Is.Not.Null);
            Assert.That(_dataManager.GetRelationEndPointWithoutLoading(virtualEndPointID).IsDataComplete, Is.True);

            UnloadService.UnloadData(TestableClientTransaction, employee.Computer.ID);
            Assert.That(_dataManager.GetRelationEndPointWithoutLoading(virtualEndPointID), Is.Not.Null);
            Assert.That(_dataManager.GetRelationEndPointWithoutLoading(virtualEndPointID).IsDataComplete, Is.False);

            UnloadService.UnloadData(TestableClientTransaction, unsynchronizedComputer.ID);
            Assert.That(_dataManager.GetRelationEndPointWithoutLoading(virtualEndPointID), Is.Null);
        }
 protected ObjectID CreateCompanyAndSetIndustrialSectorInOtherTransaction(ObjectID industrialSectorID)
 {
     return(RelationInconcsistenciesTestHelper.CreateObjectAndSetRelationInOtherTransaction <Company, IndustrialSector> (industrialSectorID, (c, s) =>
     {
         c.IndustrialSector = s;
         c.Ceo = Ceo.NewObject();
     }));
 }
        public void UnloadUnsynchronizedFK_LeavesCompleteEmptyCollection()
        {
            SetDatabaseModifyable();

            var employee = DomainObjectIDs.Employee3.GetObject <Employee> ();

            employee.Subordinates.EnsureDataComplete();
            Assert.That(employee.Subordinates, Is.Empty);

            var unsynchronizedSubordinateID =
                RelationInconcsistenciesTestHelper.CreateObjectAndSetRelationInOtherTransaction <Employee, Employee> (
                    employee.ID,
                    (subOrdinate, e) => subOrdinate.Supervisor = e);
            var unsynchronizedSubordinate = unsynchronizedSubordinateID.GetObject <Employee> ();

            var virtualEndPointID = RelationEndPointID.Resolve(employee, o => o.Subordinates);

            Assert.That(_dataManager.GetRelationEndPointWithoutLoading(virtualEndPointID), Is.Not.Null);
            Assert.That(_dataManager.GetRelationEndPointWithoutLoading(virtualEndPointID).IsDataComplete, Is.True);

            UnloadService.UnloadData(TestableClientTransaction, unsynchronizedSubordinate.ID);
            Assert.That(_dataManager.GetRelationEndPointWithoutLoading(virtualEndPointID), Is.Not.Null);
            Assert.That(_dataManager.GetRelationEndPointWithoutLoading(virtualEndPointID).IsDataComplete, Is.True);
        }
Exemplo n.º 5
0
 protected void SetEmployeeInOtherTransaction(ObjectID computerID, ObjectID employeeID)
 {
     RelationInconcsistenciesTestHelper.SetRelationInOtherTransaction <Computer, Employee> (computerID, employeeID, (c, e) => c.Employee = e);
 }
Exemplo n.º 6
0
 protected ObjectID CreateComputerAndSetEmployeeInOtherTransaction(ObjectID employeeID)
 {
     return(RelationInconcsistenciesTestHelper.CreateObjectAndSetRelationInOtherTransaction <Computer, Employee> (employeeID, (c, e) => c.Employee = e));
 }
Exemplo n.º 7
0
 protected void SetIndustrialSectorInOtherTransaction(ObjectID companyID, ObjectID industrialSectorID)
 {
     RelationInconcsistenciesTestHelper.SetRelationInOtherTransaction <Company, IndustrialSector> (companyID, industrialSectorID, (c, s) => c.IndustrialSector = s);
 }