public void OnLoaded_CannotCauseSameObjectToBeLoadedInSubTx_WhileItIsLoadedIntoParent_InitiatedFromParent()
        {
            using (_loadEventReceiverMock.GetMockRepository().Ordered())
            {
                _loadEventReceiverMock
                .Expect(mock => mock.OnLoaded(_order))
                .WhenCalled(
                    mi =>
                {
                    Assert.That(ClientTransaction.Current, Is.SameAs(ReadOnlyRootTransaction));
                    Assert.That(
                        () => WriteableSubTransaction.EnsureDataAvailable(_order.ID),
                        Throws.InvalidOperationException.With.Message.EqualTo(
                            "It's not possible to load objects into a subtransaction while they are being loaded into a parent transaction: "
                            + "'Order|5682f032-2f0b-494b-a31c-c97f02b89c36|System.Guid'."));
                });

                ReadOnlyRootTransaction.EnsureDataAvailable(_order.ID);

                _loadEventReceiverMock.VerifyAllExpectations();

                CheckState(ReadOnlyRootTransaction, _order, StateType.Unchanged);
                CheckState(ReadOnlyMiddleTransaction, _order, StateType.NotLoadedYet);
                CheckState(WriteableSubTransaction, _order, StateType.NotLoadedYet);
            }
        }
Exemplo n.º 2
0
        public void EnsureDataAvailableInReadOnlyRootTransaction_IsAllowed()
        {
            CheckDataNotLoaded(ReadOnlyRootTransaction, DomainObjectIDs.Order1);
            CheckDataNotLoaded(ReadOnlyMiddleTransaction, DomainObjectIDs.Order1);
            CheckDataNotLoaded(WriteableSubTransaction, DomainObjectIDs.Order1);

            ReadOnlyRootTransaction.EnsureDataAvailable(_order1.ID);

            CheckDataLoaded(ReadOnlyRootTransaction, _order1);
            CheckDataNotLoaded(ReadOnlyMiddleTransaction, _order1);
            CheckDataNotLoaded(WriteableSubTransaction, _order1);
        }