public void Initialization_WithInvalidObjects()
        {
            var manager = new InvalidDomainObjectManager(_transactionEventSinkWithMock, new[] { _order1 });

            Assert.That(manager.InvalidObjectCount, Is.EqualTo(1));
            Assert.That(manager.IsInvalid(_order1.ID), Is.True);
            Assert.That(manager.GetInvalidObjectReference(_order1.ID), Is.SameAs(_order1));

            _transactionEventSinkWithMock.AssertWasNotCalled(mock => mock.RaiseObjectMarkedInvalidEvent(Arg <DomainObject> .Is.Anything));
        }
Пример #2
0
        public void Begin()
        {
            _transactionEventSinkWithMock.Replay();

            _command.Begin();

            _transactionEventSinkWithMock.AssertWasNotCalled(mock => mock.RaiseRelationChangingEvent(
                                                                 Arg <DomainObject> .Is.Anything,
                                                                 Arg <IRelationEndPointDefinition> .Is.Anything,
                                                                 Arg <DomainObject> .Is.Anything,
                                                                 Arg <DomainObject> .Is.Anything));
        }
        public void CreateSubTransaction_InvalidFactory()
        {
            _thisEventSinkWithStrictMock.Expect(mock => mock.RaiseSubTransactionCreatingEvent());

            var fakeSubTransaction = ClientTransactionObjectMother.CreateWithParent(null);
            Func <ClientTransaction, ClientTransaction> factory = tx => fakeSubTransaction;

            Assert.That(
                () => _manager.CreateSubTransaction(factory),
                Throws.InvalidOperationException.With.Message.EqualTo("The given factory did not create a sub-transaction for this transaction."));

            _thisEventSinkWithStrictMock.AssertWasNotCalled(mock => mock.RaiseSubTransactionCreatedEvent(Arg <ClientTransaction> .Is.Anything));
            _thisEventSinkWithStrictMock.VerifyAllExpectations();

            Assert.That(_manager.SubTransaction, Is.Null);
            Assert.That(_manager.IsWriteable, Is.True);
        }
        public void OnBeforeObjectRegistration_ExceptionInInnerListener()
        {
            var loadedObjectIDs = Array.AsReadOnly(new[] { DomainObjectIDs.Order1, DomainObjectIDs.Order3 });

            var exception = new Exception("Test");

            using (_mockRepository.Ordered())
            {
                _hierarchyManagerMock.Expect(mock => mock.OnBeforeObjectRegistration(loadedObjectIDs)).Throw(exception);
            }
            _mockRepository.ReplayAll();

            Assert.That(() => _decorator.OnBeforeObjectRegistration(loadedObjectIDs), Throws.Exception.SameAs(exception));

            _eventSinkWithMock.AssertWasNotCalled(mock => mock.RaiseObjectsLoadingEvent(Arg <ReadOnlyCollection <ObjectID> > .Is.Anything));
            _hierarchyManagerMock.VerifyAllExpectations();
        }
        public void End_WithoutPerform()
        {
            _dataContainerMap.Register(_existingDataContainer);
            _dataContainerMap.Register(_newDataContainer);

            _unloadCommand.End();

            _transactionEventSinkWithMock.AssertWasNotCalled(mock => mock.RaiseObjectsUnloadedEvent(Arg <ReadOnlyCollection <DomainObject> > .Is.Anything));
        }
        public void MarkDataIncomplete_Throws_WithChangedData()
        {
            _virtualEndPointMock
            .Stub(stub => stub.ID)
            .Return(RelationEndPointID.Create(DomainObjectIDs.Customer1, _definition));
            _virtualEndPointMock.Replay();

            _dataManagerMock.Stub(stub => stub.HasDataChanged()).Return(true);
            _dataManagerMock.Replay();

            _transactionEventSinkWithMock.Replay();

            Assert.That(
                () => _loadState.MarkDataIncomplete(_virtualEndPointMock, () => Assert.Fail("Must not be called.")),
                Throws.InvalidOperationException.With.Message.EqualTo(
                    "Cannot mark virtual end-point "
                    + "'Customer|55b52e75-514b-4e82-a91b-8f0bb59b80ad|System.Guid/Remotion.Data.DomainObjects.UnitTests.TestDomain.Customer.Orders' incomplete "
                    + "because it has been changed."));

            _transactionEventSinkWithMock.AssertWasNotCalled(mock => mock.RaiseRelationEndPointBecomingIncompleteEvent(Arg <RelationEndPointID> .Is.Anything));
        }