public void Commit_Method()
 {
   using (var connection = this.sessionFactory.OpenSession())
   {
     var transaction = new NHibernateTransaction(connection);
     Assert.True(ReferenceEquals(transaction.Commit(), transaction));
     Assert.False(transaction.Field("disposed").To<bool>());
     Assert.True(transaction.Field("wasCommitted").To<bool>());
     Assert.False(transaction.Field("wasRolledBack").To<bool>());
   }
 }
Ejemplo n.º 2
0
 public void Rollback_Method()
 {
     using (var connection = this.sessionFactory.OpenSession())
     {
         var transaction = new NHibernateTransaction(connection);
         Assert.True(ReferenceEquals(transaction.Rollback(), transaction));
         Assert.False(transaction.Field("disposed").To <bool>());
         Assert.False(transaction.Field("wasCommitted").To <bool>());
         Assert.True(transaction.Field("wasRolledBack").To <bool>());
     }
 }
 public void Dispose_Method()
 {
   using (var connection = this.sessionFactory.OpenSession())
   {
     var transaction = new NHibernateTransaction(connection);
     transaction.Dispose();
     Assert.True(transaction.Field("disposed").To<bool>());
     Assert.False(transaction.Field("wasCommitted").To<bool>());
     Assert.False(transaction.Field("wasRolledBack").To<bool>());
     Assert.Throws<ObjectDisposedException>(() => transaction.Dispose());
   }
 }
Ejemplo n.º 4
0
 public void Dispose_Method()
 {
     using (var connection = this.sessionFactory.OpenSession())
     {
         var transaction = new NHibernateTransaction(connection);
         transaction.Dispose();
         Assert.True(transaction.Field("disposed").To <bool>());
         Assert.False(transaction.Field("wasCommitted").To <bool>());
         Assert.False(transaction.Field("wasRolledBack").To <bool>());
         Assert.Throws <ObjectDisposedException>(() => transaction.Dispose());
     }
 }
 public void Constructors()
 {
   Assert.Throws<ArgumentNullException>(() => new NHibernateTransaction(null));
   
   using (var connection = this.sessionFactory.OpenSession())
   {
     using (var transaction = new NHibernateTransaction(connection))
     {
       Assert.Equal(IsolationLevel.Unspecified, transaction.IsolationLevel);
       Assert.False(transaction.Field("disposed").To<bool>());
       Assert.False(transaction.Field("wasCommitted").To<bool>());
       Assert.False(transaction.Field("wasRolledBack").To<bool>());
     }
     using (var transaction = new NHibernateTransaction(connection, IsolationLevel.ReadCommitted))
     {
       Assert.Equal(IsolationLevel.ReadCommitted, transaction.IsolationLevel);
       Assert.False(transaction.Field("disposed").To<bool>());
       Assert.False(transaction.Field("wasCommitted").To<bool>());
       Assert.False(transaction.Field("wasRolledBack").To<bool>());
     }
   }
 }
Ejemplo n.º 6
0
        public void Constructors()
        {
            Assert.Throws <ArgumentNullException>(() => new NHibernateTransaction(null));

            using (var connection = this.sessionFactory.OpenSession())
            {
                using (var transaction = new NHibernateTransaction(connection))
                {
                    Assert.Equal(IsolationLevel.Unspecified, transaction.IsolationLevel);
                    Assert.False(transaction.Field("disposed").To <bool>());
                    Assert.False(transaction.Field("wasCommitted").To <bool>());
                    Assert.False(transaction.Field("wasRolledBack").To <bool>());
                }
                using (var transaction = new NHibernateTransaction(connection, IsolationLevel.ReadCommitted))
                {
                    Assert.Equal(IsolationLevel.ReadCommitted, transaction.IsolationLevel);
                    Assert.False(transaction.Field("disposed").To <bool>());
                    Assert.False(transaction.Field("wasCommitted").To <bool>());
                    Assert.False(transaction.Field("wasRolledBack").To <bool>());
                }
            }
        }