Exemple #1
0
        void DoSingleCommit(ISinglePhaseNotification single)
        {
            if (single == null)
            {
                return;
            }

            single.SinglePhaseCommit(new SinglePhaseEnlistment(this, single));
            CheckAborted();
        }
Exemple #2
0
        void ISinglePhaseNotificationInternal.SinglePhaseCommit(IPromotedEnlistment singlePhaseEnlistment)
        {
            bool spcCommitted = false;

            _promotedEnlistment = singlePhaseEnlistment;
            try
            {
                _singlePhaseNotifications.SinglePhaseCommit(SinglePhaseEnlistment);
                spcCommitted = true;
            }
            finally
            {
                if (!spcCommitted)
                {
                    SinglePhaseEnlistment.InDoubt();
                }
            }
        }
        public void InDoubt()
        {
            var tso = new Transactional <SimpleObject>();

            SimpleObject obj = new SimpleObject
            {
                TestInt    = 7,
                TestGuid   = Guid.NewGuid(),
                TestString = "Testing"
            };

            MockRepository mocks = new MockRepository();

            ISinglePhaseNotification badResource = mocks.StrictMock <ISinglePhaseNotification>();

            badResource.SinglePhaseCommit(null);

            Action <SinglePhaseEnlistment> onCommit = (SinglePhaseEnlistment spe) => spe.InDoubt();

            LastCall.IgnoreArguments().Do(onCommit);

            mocks.ReplayAll();

            Assert.Throws <TransactionInDoubtException>(() =>
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    tso.Value = obj;
                    Transaction.Current.EnlistDurable(Guid.NewGuid(), badResource, EnlistmentOptions.None);

                    scope.Complete();
                }
            });

            Assert.IsNull(tso.Value);
        }
Exemple #4
0
		void DoSingleCommit (ISinglePhaseNotification single)
		{
			if (single == null)
				return;

			single.SinglePhaseCommit (new SinglePhaseEnlistment (this, single));
			CheckAborted ();
		}