public void GetLoadedObject_Known()
        {
            var dataContainer = DataContainer.CreateForExisting(DomainObjectIDs.Order1, null, pd => pd.DefaultValue);

            dataContainer.SetDomainObject(DomainObjectMother.CreateFakeObject <Order> (dataContainer.ID));
            DataContainerTestHelper.SetClientTransaction(dataContainer, ClientTransaction.CreateRootTransaction());

            _invalidDomainObjectManagerMock
            .Stub(mock => mock.IsInvalid(DomainObjectIDs.Order1))
            .Return(false);
            _invalidDomainObjectManagerMock.Replay();

            _loadedDataContainerProviderMock
            .Expect(mock => mock.GetDataContainerWithoutLoading(DomainObjectIDs.Order1))
            .Return(dataContainer);
            _loadedDataContainerProviderMock.Replay();

            var loadedObject = _dataProvider.GetLoadedObject(DomainObjectIDs.Order1);

            _loadedDataContainerProviderMock.VerifyAllExpectations();
            Assert.That(
                loadedObject,
                Is.TypeOf <AlreadyExistingLoadedObjectData> ()
                .With.Property((AlreadyExistingLoadedObjectData obj) => obj.ExistingDataContainer).SameAs(dataContainer));
        }
        public void CreateInvalidDomainObjectManager()
        {
            _parentInvalidDomainObjectManagerStub.Stub(stub => stub.InvalidObjectIDs).Return(new ObjectID[0]);
            var eventSink = MockRepository.GenerateStub <IClientTransactionEventSink>();

            var manager = _factory.CreateInvalidDomainObjectManager(_fakeConstructedTransaction, eventSink);

            Assert.That(manager, Is.TypeOf(typeof(InvalidDomainObjectManager)));
            Assert.That(((InvalidDomainObjectManager)manager).TransactionEventSink, Is.SameAs(eventSink));
        }
        public void End_WithPerform()
        {
            _dataContainerMap.Register(_existingDataContainer);
            _dataContainerMap.Register(_newDataContainer);

            _invalidDomainObjectManagerMock.Stub(mock => mock.MarkInvalid(Arg <DomainObject> .Is.Anything)).Return(true);
            _endPointManagerMock.Stub(mock => mock.Reset());
            _unloadCommand.Perform();

            // Order of registration
            _transactionEventSinkWithMock.Expect(mock => mock.RaiseObjectsUnloadedEvent(
                                                     Arg <ReadOnlyCollection <DomainObject> > .List.Equal(new[] { _existingDataContainer.DomainObject, _newDataContainer.DomainObject })));

            _unloadCommand.End();

            _transactionEventSinkWithMock.VerifyAllExpectations();
        }
Exemplo n.º 4
0
        public void GetObjectReference_KnownObject_ReturnedWithoutLoading()
        {
            _invalidDomainObjectManagerMock.Stub(stub => stub.IsInvalid(_objectIDWithCreatorMock)).Return(false);
            _enlistedDomainObjectManagerMock.Expect(mock => mock.GetEnlistedDomainObject(_objectIDWithCreatorMock)).Return(_domainObject1);

            var result = _agent.GetObjectReference(_objectIDWithCreatorMock);

            _enlistedDomainObjectManagerMock.VerifyAllExpectations();
            _domainObjectCreatorMock.AssertWasNotCalled(
                mock => mock.CreateObjectReference(Arg <IObjectInitializationContext> .Is.Anything, Arg <ClientTransaction> .Is.Anything));

            Assert.That(result, Is.SameAs(_domainObject1));
        }