public void EnlistInTransaction_enlist()
		{
			var target = new TransactionEnlistmentHelper();

			bool ensureTransaction = true;
			EnlistmentOptions options = EnlistmentOptions.None;

			var enlistmentNotification = MockRepository.GenerateMock<IEnlistmentNotification>();
			enlistmentNotification.Expect( en => en.Prepare( null ) )
				.IgnoreArguments()
				.WhenCalled( a =>
				{
					PreparingEnlistment e = a.Arguments.GetValue( 0 ) as PreparingEnlistment;
					e.Prepared();
				} )
				.Repeat.Once();

			enlistmentNotification.Expect( en => en.Commit( null ) )
				.IgnoreArguments()
				.WhenCalled( a =>
				{
					Enlistment e = a.Arguments.GetValue( 0 ) as Enlistment;
					e.Done();
				} )
				.Repeat.Once();

			using( var ts = new TransactionScope() )
			{
				target.EnlistInTransaction( ensureTransaction, enlistmentNotification, options );
				ts.Complete();
			}

			enlistmentNotification.VerifyAllExpectations();
		}
        public void EnlistInTransaction_with_null_iEnlistmentNotification()
        {
            TransactionEnlistmentHelper target = new TransactionEnlistmentHelper();

            bool ensureTransaction = false;
            IEnlistmentNotification enlistmentNotification = null;
            EnlistmentOptions options = EnlistmentOptions.None;

            target.EnlistInTransaction( ensureTransaction, enlistmentNotification, options );
        }
        public void EnlistInTransaction_without_transaction_and_no_ensure()
        {
            TransactionEnlistmentHelper target = new TransactionEnlistmentHelper();

            bool ensureTransaction = false;
            IEnlistmentNotification enlistmentNotification = MockRepository.GenerateMock<IEnlistmentNotification>();
            EnlistmentOptions options = EnlistmentOptions.None;

            target.EnlistInTransaction( ensureTransaction, enlistmentNotification, options );

            enlistmentNotification.VerifyAllExpectations();
        }
        public void EnlistInTransaction_already_enlisted_in_a_different_transaction()
        {
            TransactionEnlistmentHelper target = new TransactionEnlistmentHelper();

            bool ensureTransaction = true;
            IEnlistmentNotification enlistmentNotification = MockRepository.GenerateMock<IEnlistmentNotification>();
            EnlistmentOptions options = EnlistmentOptions.None;

            using( TransactionScope ts1 = new TransactionScope() )
            {
                target.EnlistInTransaction( ensureTransaction, enlistmentNotification, options );

                using( TransactionScope ts2 = new TransactionScope( TransactionScopeOption.RequiresNew ) )
                {
                    target.EnlistInTransaction( ensureTransaction, enlistmentNotification, options );
                    ts2.Complete();
                }

                ts1.Complete();
            }
        }