public void UnloadData_NonLoadedObject()
        {
            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(TestableClientTransaction);

            UnloadService.UnloadData(TestableClientTransaction, DomainObjectIDs.Order1);

            Assert.That(TestableClientTransaction.GetEnlistedDomainObject(DomainObjectIDs.Order1), Is.Null);
        }
        public void UnloadVirtualEndPoint_Collection_AlreadyUnloaded()
        {
            var customer = DomainObjectIDs.Customer1.GetObject <Customer> ();
            var endPoint = DomainObjectCollectionDataTestHelper.GetAssociatedEndPoint(customer.Orders);

            UnloadService.UnloadVirtualEndPoint(TestableClientTransaction, endPoint.ID);
            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(TestableClientTransaction);
            Assert.That(endPoint.IsDataComplete, Is.False);

            UnloadService.UnloadVirtualEndPoint(TestableClientTransaction, endPoint.ID);
        }
        public void UnloadVirtualEndPointAndItemData_DoesNothing_IfEndPointNotLoaded()
        {
            var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Customer1, "Orders");

            Assert.That(TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading(endPointID), Is.Null);

            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(TestableClientTransaction);

            UnloadService.UnloadVirtualEndPointAndItemData(TestableClientTransaction, endPointID);

            Assert.That(TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading(endPointID), Is.Null);
        }
        public void UnloadData_AlreadyUnloaded()
        {
            var order1 = DomainObjectIDs.Order1.GetObject <Order> ();

            UnloadService.UnloadData(TestableClientTransaction, order1.ID);
            Assert.That(order1.State, Is.EqualTo(StateType.NotLoadedYet));
            Assert.That(TestableClientTransaction.GetEnlistedDomainObject(DomainObjectIDs.Order1), Is.SameAs(order1));

            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(TestableClientTransaction);

            UnloadService.UnloadData(TestableClientTransaction, order1.ID);

            Assert.That(order1.State, Is.EqualTo(StateType.NotLoadedYet));
        }
Beispiel #5
0
        public void GetValueWithoutEvents_NoEvents()
        {
            var clientTransactionMock = new TestableClientTransaction();

            using (clientTransactionMock.EnterDiscardingScope())
            {
                var dataContainer      = Order.NewObject().InternalDataContainer;
                var propertyDefinition = GetPropertyDefinition(typeof(Order), "OrderNumber");

                ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(clientTransactionMock);

                dataContainer.GetValueWithoutEvents(propertyDefinition, ValueAccess.Current);
            }
        }
        public void TryUnloadVirtualEndPointAndItemData_Success_IfDataNotComplete()
        {
            var customer       = DomainObjectIDs.Customer1.GetObject <Customer> ();
            var ordersEndPoint = DomainObjectCollectionDataTestHelper.GetAssociatedEndPoint(customer.Orders);

            UnloadService.UnloadVirtualEndPoint(TestableClientTransaction, ordersEndPoint.ID);
            Assert.That(ordersEndPoint.IsDataComplete, Is.False);

            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(TestableClientTransaction);

            var result = UnloadService.TryUnloadVirtualEndPointAndItemData(TestableClientTransaction, ordersEndPoint.ID);

            Assert.That(result, Is.True);
            Assert.That(ordersEndPoint.IsDataComplete, Is.False);
        }
        public void UnloadVirtualEndPoint_Object_AlreadyUnloaded()
        {
            var order = DomainObjectIDs.Order1.GetObject <Order> ();

            TestableClientTransaction.EnsureDataComplete(RelationEndPointID.Resolve(order, o => o.OrderTicket));

            CheckVirtualEndPointExistsAndComplete(order, "OrderTicket", true, true);

            UnloadService.UnloadVirtualEndPoint(TestableClientTransaction, RelationEndPointID.Resolve(order, o => o.OrderTicket));

            CheckVirtualEndPointExistsAndComplete(order, "OrderTicket", true, false);
            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(TestableClientTransaction);

            UnloadService.UnloadVirtualEndPoint(TestableClientTransaction, RelationEndPointID.Resolve(order, o => o.OrderTicket));
        }
        public void CopyCollectionEventHandlers_DoesNotLoadRelatedObjectsInOriginalTransaction()
        {
            Order order = DomainObjectIDs.Order1.GetObject <Order> ();
            int   loadedObjectsBefore = TestableClientTransaction.DataManager.DataContainers.Count;

            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(TestableClientTransaction);

            using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope())
            {
                ClientTransaction.Current.CopyCollectionEventHandlers(order, TestableClientTransaction);
            }

            int loadedObjectsAfter = TestableClientTransaction.DataManager.DataContainers.Count;

            Assert.That(loadedObjectsAfter, Is.EqualTo(loadedObjectsBefore));
        }
Beispiel #9
0
        public void Compare_DoesNotTriggerEvents()
        {
            var domainObject1 = DomainObjectMother.CreateFakeObject <Order> ();
            var domainObject2 = DomainObjectMother.CreateFakeObject <Order> ();

            var dataContainer1 = PrepareDataContainer(_dataManagerStub, domainObject1, 1);
            var dataContainer2 = PrepareDataContainer(_dataManagerStub, domainObject2, 2);

            var transaction = ClientTransaction.CreateRootTransaction();

            ClientTransactionTestHelper.RegisterDataContainer(transaction, dataContainer1);
            ClientTransactionTestHelper.RegisterDataContainer(transaction, dataContainer2);

            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(transaction);

            var specification = new SortedPropertySpecification(_orderNumberPropertyDefinition, SortOrder.Descending);
            var comparer      = new SortedPropertyComparer(specification, _dataManagerStub);

            Assert.That(comparer.Compare(domainObject1, domainObject1), Is.EqualTo(0));
        }
Beispiel #10
0
        public void EnsureDataComplete_DoesNothing()
        {
            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(TestableClientTransaction);

            _endPoint.EnsureDataComplete();
        }
Beispiel #11
0
        public void End_DoesNothing()
        {
            ClientTransactionTestHelperWithMocks.EnsureTransactionThrowsOnEvents(_transaction);

            _command.End();
        }