Пример #1
0
        public static void EnsureTransactionThrowsOnEvents(ClientTransaction clientTransaction)
        {
            IClientTransactionListener listenerMock = CreateAndAddListenerStrictMock(clientTransaction);

            listenerMock.Stub(stub => stub.TransactionDiscard(clientTransaction)); // allow TransactionDicarding to be called
            listenerMock.Replay();                                                 // no events expected
        }
        public override void SetUp()
        {
            base.SetUp();

            _transaction = ClientTransaction.CreateRootTransaction().CreateSubTransaction();

            _unchangedObject = GetUnchangedObject();
            _changedObject   = GetChangedObject();
            _newObject       = GetNewObject();
            _deletedObject   = GetDeletedObject();

            _mockRepository = new MockRepository();

            // Listener is a dynamic mock so that we don't have to expect all the internal events of committing
            _listenerMock  = _mockRepository.DynamicMock <IClientTransactionListener> ();
            _extensionMock = _mockRepository.StrictMock <ClientTransactionExtensionBase> ("test");
            _transactionMockEventReceiver = _mockRepository.StrictMock <ClientTransactionMockEventReceiver> (_transaction);

            _changedObjectEventReceiverMock   = CreateDomainObjectMockEventReceiver(_changedObject);
            _newObjectEventReceiverMock       = CreateDomainObjectMockEventReceiver(_newObject);
            _deletedObjectEventReceiverMock   = CreateDomainObjectMockEventReceiver(_deletedObject);
            _unchangedObjectEventReceiverMock = CreateDomainObjectMockEventReceiver(_unchangedObject);

            ClientTransactionTestHelper.AddListener(_transaction, _listenerMock);
            _transaction.Extensions.Add(_extensionMock);
        }
Пример #3
0
        public static void EnsureTransactionThrowsOnEvent(
            ClientTransaction clientTransaction,
            Action <IClientTransactionListener> forbiddenEventExpectation)
        {
            IClientTransactionListener listenerMock = CreateAndAddListenerMock(clientTransaction);

            listenerMock.Expect(forbiddenEventExpectation).WhenCalled(mi => { throw new InvalidOperationException("Forbidden event raised."); });
            listenerMock.Replay();
        }
Пример #4
0
        protected void AssertObjectWasLoadedAmongOthers(IClientTransactionListener listenerMock, DomainObject loadedObject)
        {
            ArgumentUtility.CheckNotNull("listenerMock", listenerMock);
            ArgumentUtility.CheckNotNull("loadedObject", loadedObject);

            listenerMock.AssertWasCalled(mock => mock.ObjectsLoaded(
                                             Arg.Is(ClientTransaction.Current),
                                             Arg <ReadOnlyCollection <DomainObject> > .List.IsIn(loadedObject)));
        }
 public override void SetUp()
 {
     base.SetUp();
     _listener           = NullClientTransactionListener.Instance;
     _domainObject       = DomainObjectMother.CreateObjectInTransaction <Client> (TestableClientTransaction);
     _dataContainer      = _domainObject.GetInternalDataContainerForTransaction(TestableClientTransaction);
     _propertyDefinition = GetPropertyDefinition(typeof(Client), "ParentClient");
     _relationEndPoint   = TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading(_dataContainer.AssociatedRelationEndPointIDs[0]);
 }
        public override void SetUp()
        {
            base.SetUp();

            _mockRepository = new MockRepository();

            _listener1 = _mockRepository.StrictMock <IClientTransactionListener> ();
            _listener2 = _mockRepository.StrictMock <IClientTransactionListener> ();

            _compoundListener = new CompoundClientTransactionListener();
        }
        public override void SetUp()
        {
            base.SetUp();

            _loadedObject1              = DomainObjectMother.GetUnchangedObject(TestableClientTransaction, DomainObjectIDs.Order1);
            _loadedObject2              = DomainObjectMother.GetUnchangedObject(TestableClientTransaction, DomainObjectIDs.Order3);
            _notLoadedObject1           = DomainObjectMother.GetNotLoadedObject(TestableClientTransaction, DomainObjectIDs.Order4);
            _notLoadedObject2           = DomainObjectMother.GetNotLoadedObject(TestableClientTransaction, DomainObjectIDs.Order5);
            _invalidObject              = DomainObjectMother.GetInvalidObject(TestableClientTransaction);
            _notLoadedNonExistingObject = DomainObjectMother.GetNotLoadedObject(TestableClientTransaction, new ObjectID(typeof(ClassWithAllDataTypes), Guid.NewGuid()));

            _listenerMock = ClientTransactionTestHelperWithMocks.CreateAndAddListenerMock(TestableClientTransaction);
        }
        public override void SetUp()
        {
            base.SetUp();

            _listenerDynamicMock = MockRepository.GenerateMock <IClientTransactionListener> ();
            _extensionStrictMock = MockRepository.GenerateStrictMock <IClientTransactionExtension> ();

            _readOnlyRootTransaction = ClientTransaction.CreateRootTransaction();
            ExecuteInReadOnlyRootTransaction(InitializeReadOnlyRootTransaction);
            _readOnlyMiddleTransaction = ReadOnlyRootTransaction.CreateSubTransaction();
            ExecuteInReadOnlyMiddleTransaction(InitializeReadOnlyMiddleTransaction);
            _writeableSubTransaction = ReadOnlyMiddleTransaction.CreateSubTransaction();
            ExecuteInWriteableSubTransaction(InitializeWriteableSubTransaction);
        }
Пример #9
0
        public override void SetUp()
        {
            base.SetUp();

            _clientTransaction = ClientTransaction.CreateRootTransaction();

            _eventBroker = new ClientTransactionEventBroker(_clientTransaction);

            _domainObject1       = _clientTransaction.ExecuteInScope(() => DomainObjectIDs.Order1.GetObject <Order> ());
            _domainObject2       = _clientTransaction.ExecuteInScope(() => DomainObjectIDs.Order3.GetObject <Order> ());
            _invalidDomainObject = _clientTransaction.ExecuteInScope(
                () =>
            {
                var order = Order.NewObject();
                order.Delete();
                return(order);
            });

            _mockRepository                 = new MockRepository();
            _order1EventReceiverMock        = _mockRepository.StrictMock <DomainObjectMockEventReceiver> (_domainObject1);
            _order2EventReceiverMock        = _mockRepository.StrictMock <DomainObjectMockEventReceiver> (_domainObject2);
            _invalidObjectEventReceiverMock = _mockRepository.StrictMock <DomainObjectMockEventReceiver> (_invalidDomainObject);

            _unloadEventReceiverMock = _mockRepository.StrictMock <IUnloadEventReceiver> ();
            ((TestDomainBase)_domainObject1).SetUnloadEventReceiver(_unloadEventReceiverMock);
            ((TestDomainBase)_domainObject2).SetUnloadEventReceiver(_unloadEventReceiverMock);

            _transactionEventReceiverMock = _mockRepository.StrictMock <ClientTransactionMockEventReceiver> (_clientTransaction);

            _loadEventReceiverMock = _mockRepository.StrictMock <ILoadEventReceiver> ();
            ((TestDomainBase)_domainObject1).SetLoadEventReceiver(_loadEventReceiverMock);
            ((TestDomainBase)_domainObject2).SetLoadEventReceiver(_loadEventReceiverMock);

            _extensionMock = _mockRepository.StrictMock <IClientTransactionExtension> ();
            _extensionMock.Stub(stub => stub.Key).Return("extension");
            _extensionMock.Replay();
            _eventBroker.Extensions.Add(_extensionMock);
            _extensionMock.BackToRecord();

            _listenerMock = _mockRepository.StrictMock <IClientTransactionListener> ();
            _eventBroker.AddListener(_listenerMock);
        }
Пример #10
0
 public void RemoveListener(IClientTransactionListener listener)
 {
     ArgumentUtility.CheckNotNull("listener", listener);
     _listenerCollection.RemoveListener(listener);
 }
Пример #11
0
 public static void RemoveListener(ClientTransaction clientTransaction, IClientTransactionListener listener)
 {
     PrivateInvoke.InvokeNonPublicMethod(clientTransaction, "RemoveListener", listener);
 }
        public void AddListener(IClientTransactionListener listener)
        {
            ArgumentUtility.CheckNotNull("listener", listener);

            _listeners.Add(listener);
        }
Пример #13
0
        public override void SetUp()
        {
            base.SetUp();

            _listenerDynamicMock = ClientTransactionTestHelperWithMocks.CreateAndAddListenerMock(TestableClientTransaction);
        }
 public new void RemoveListener(IClientTransactionListener listener)
 {
     base.RemoveListener(listener);
 }
 public new void AddListener(IClientTransactionListener listener)
 {
     base.AddListener(listener);
 }