示例#1
0
 public void UsingTransactionScope()
 {
     using (new TransactionScope())
     {
         new SSAFEntity("example").Save();
         //Assert.AreEqual(1, SSAFEntity.FindAll().Length);
     }
     using (new SessionScope())
         Assert.AreEqual(1, SSAFEntity.FindAll().Count());
 }
示例#2
0
 public void UsingNoFlushSessionScope()
 {
     using (new SessionScope(FlushAction.Never))
     {
         new SSAFEntity("example").Save();
         Assert.AreEqual(0, SSAFEntity.FindAll().Count());
     }
     using (new SessionScope())
         Assert.AreEqual(0, SSAFEntity.FindAll().Count());
 }
示例#3
0
 public void ActiveRecordUsingTransactionScope()
 {
     InitModel();
     using (new TransactionScope())
     {
         new SSAFEntity("example").Save();
         //Assert.AreEqual(1, SSAFEntity.FindAll().Length);
     }
     Assert.AreEqual(1, SSAFEntity.FindAll().Length);
 }
示例#4
0
 public void UsingSessionScope()
 {
     using (new SessionScope())
     {
         new SSAFEntity("example").Save();
         Assert.AreEqual(1, SSAFEntity.FindAll().Count());
     }
     using (new SessionScope())
         Assert.AreEqual(1, SSAFEntity.FindAll().Count());
 }
示例#5
0
 public void ActiveRecordUsingNoFlushSessionScope()
 {
     InitModel();
     using (new SessionScope(FlushAction.Never))
     {
         new SSAFEntity("example").Save();
         Assert.AreEqual(0, SSAFEntity.FindAll().Length);
     }
     Assert.AreEqual(0, SSAFEntity.FindAll().Length);
 }
示例#6
0
 public void UsingTransactionScopeWithRollback()
 {
     using (TransactionScope scope = new TransactionScope())
     {
         new SSAFEntity("example").Save();
         //Assert.AreEqual(1, SSAFEntity.FindAll().Length);
         scope.VoteRollBack();
     }
     using (new SessionScope())
         Assert.AreEqual(0, SSAFEntity.FindAll().Count());
 }
示例#7
0
 public void UsingSessionScopeUsingExplicitFlush()
 {
     using (var scope = new SessionScope())
     {
         new SSAFEntity("example").Save();
         scope.Flush();
         Assert.AreEqual(1, SSAFEntity.FindAll().Count());
     }
     using (new SessionScope())
         Assert.AreEqual(1, SSAFEntity.FindAll().Count());
 }
示例#8
0
 public void ActiveRecordUsingTransactionScopeWithRollback()
 {
     InitModel();
     using (TransactionScope scope = new TransactionScope())
     {
         new SSAFEntity("example").Save();
         //Assert.AreEqual(1, SSAFEntity.FindAll().Length);
         scope.VoteRollBack();
     }
     Assert.AreEqual(0, SSAFEntity.FindAll().Length);
 }
示例#9
0
 public void ActiveRecordUsingSessionScopeUsingExplicitFlush()
 {
     InitModel();
     using (new SessionScope())
     {
         new SSAFEntity("example").Save();
         SessionScope.Current.Flush();
         Assert.AreEqual(1, SSAFEntity.FindAll().Length);
     }
     Assert.AreEqual(1, SSAFEntity.FindAll().Length);
 }
示例#10
0
 public void UsingTransactionScopeWithCommitAndInnerSessionScope()
 {
     using (TransactionScope scope = new TransactionScope())
     {
         using (new SessionScope())
         {
             new SSAFEntity("example").Save();
             Assert.AreEqual(1, SSAFEntity.FindAll().Count());
         }
         //Assert.AreEqual(1, SSAFEntity.FindAll().Length);
         scope.VoteCommit();
     }
     using (new SessionScope())
         Assert.AreEqual(1, SSAFEntity.FindAll().Count());
 }
示例#11
0
        public void UsingNestedTransactionScopesWithRollback()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                using (new TransactionScope(TransactionMode.Inherits))
                {
                    new SSAFEntity("example").Save();
                    Assert.AreEqual(1, SSAFEntity.FindAll().Count());
                }
                Assert.AreEqual(1, SSAFEntity.FindAll().Count());
                scope.VoteRollBack();
            }

            using (new SessionScope())
                Assert.AreEqual(0, SSAFEntity.FindAll().Count());
        }