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

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

private NestedTransactionScope7 ( ) : void
Результат void
        public void NestedTransactionScope7()
        {
            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(TransactionScopeOption.RequiresNew))
                {
                    irm2.Value = 20;
                    /* Not completing
                     scope2.Complete();*/
                }

                /* irm2, rolled back*/
                irm2.Check(0, 0, 1, 0, "irm2");
                Assert.Equal(irm2.Value, 10);

                Assert.Equal(TransactionStatus.Active, Transaction.Current.TransactionInformation.Status);

                scope.Complete();
            }

            Assert.Null(Transaction.Current);
            /* ..But irm got committed */
            Assert.Equal(irm.Value, 2);
            irm.Check(1, 1, 0, 0, "irm");
        }