public override void Reset()
        {
            if (_scope != null)
            {
                _scope.Leave();
                _transaction.Release();
                _transaction = CreateTransaction();
                EnterScope();
            }
            else
            {
                _transaction.Release();
                _transaction = CreateTransaction();
            }

            var variables = _executionContext.GetVariables();

            try
            {
                EnsureCompatibility(variables);
            }
            catch (InvalidOperationException ex)
            {
                var message =
                    "One or more of the variables of the WxeFunction are incompatible with the new transaction after the Reset. "
                    + ex.Message
                    + " (To avoid this exception, clear the Variables collection from incompatible objects before calling Reset and repopulate it "
                    + "afterwards.)";
                throw new WxeException(message, ex);
            }
        }
Ejemplo n.º 2
0
        public void ITransactionScope_IsActiveScope()
        {
            ClientTransaction clientTransaction = ClientTransaction.CreateRootTransaction();

            try
            {
                ITransactionScope outerScope = clientTransaction.EnterDiscardingScope();
                Assert.That(outerScope.IsActiveScope, Is.True);

                using (ClientTransactionScope innerScope = clientTransaction.CreateSubTransaction().EnterDiscardingScope())
                {
                    Assert.That(outerScope.IsActiveScope, Is.False);
                    Assert.That(((ITransactionScope)innerScope).IsActiveScope, Is.True);
                }

                Assert.That(outerScope.IsActiveScope, Is.True);
                outerScope.Leave();
                Assert.That(outerScope.IsActiveScope, Is.False);
            }
            finally
            {
                ClientTransactionScope.ResetActiveScope(); // for TearDown
            }
        }