System.Transactions.Tests.TransactionScopeTest.NestedTransactionScope4 C# (CSharp) Метод

NestedTransactionScope4() приватный Метод

private NestedTransactionScope4 ( ) : void
Результат void
        public void NestedTransactionScope4()
        {
            IntResourceManager irm = new IntResourceManager(1);
            IntResourceManager irm2 = new IntResourceManager(10);

            Assert.Null(Transaction.Current);
            using (TransactionScope scope = new TransactionScope())
            {
                irm.Value = 2;

                using (TransactionScope scope2 = new TransactionScope())
                {
                    irm2.Value = 20;

                    /* Inner Tx not completed, Tx should get rolled back */
                    //scope2.Complete();
                }
                /* Both rolledback */
                irm.Check(0, 0, 1, 0, "irm");
                irm2.Check(0, 0, 1, 0, "irm2");
                Assert.Equal(TransactionStatus.Aborted, Transaction.Current.TransactionInformation.Status);
                //scope.Complete ();
            }

            Assert.Null(Transaction.Current);

            Assert.Equal(irm.Value, 1);
            Assert.Equal(irm2.Value, 10);
            irm.Check(0, 0, 1, 0, "irm");
        }