Exemple #1
0
        public void DC_Dispose()
        {
            SnDataContext   dataContext     = null;
            TestConnection  testConnection  = null;
            TestTransaction testTransaction = null;

            try
            {
                using (dataContext = new TestDataContext(CancellationToken.None))
                {
                    Assert.IsFalse(dataContext.IsDisposed);
                    using (var transaction = dataContext.BeginTransaction(IsolationLevel.ReadCommitted, TimeSpan.FromMinutes(10)))
                    {
                        testConnection  = (TestConnection)dataContext.Connection;
                        testTransaction = (TestTransaction)dataContext.Transaction.Transaction;
                        throw new SnNotSupportedException();
                    }
                }
            }
            catch (SnNotSupportedException)
            {
                // do nothing
            }
            Assert.IsTrue(testConnection.State == ConnectionState.Closed);
            Assert.IsTrue(testTransaction.IsRollbackCalled);
            Assert.IsTrue(dataContext.IsDisposed);
        }