コード例 #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)));
        }
コード例 #5
0
 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();
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
 }
コード例 #12
0
        public void AddListener(IClientTransactionListener listener)
        {
            ArgumentUtility.CheckNotNull("listener", listener);

            _listeners.Add(listener);
        }
コード例 #13
0
        public override void SetUp()
        {
            base.SetUp();

            _listenerDynamicMock = ClientTransactionTestHelperWithMocks.CreateAndAddListenerMock(TestableClientTransaction);
        }
コード例 #14
0
 public new void RemoveListener(IClientTransactionListener listener)
 {
     base.RemoveListener(listener);
 }
コード例 #15
0
 public new void AddListener(IClientTransactionListener listener)
 {
     base.AddListener(listener);
 }