Exemplo n.º 1
0
 public void GetConnection_ShouldGetDifferentConnectionOnDifferentThreads()
 {
     using (TransactionScope scope = new TransactionScope())
     {
         DatabaseConnectionWrapper connection = TransactionScopeConnections.GetConnection(db);
         ThreadTests tests  = new ThreadTests();
         Thread      thread = new Thread(tests.GetTransactionScopeConnection);
         thread.Start();
         thread.Join();
         Assert.AreNotSame(connection, tests.Connection);
     }
 }
Exemplo n.º 2
0
 public void GetConnection_ShouldGetSameConnectionWhenOtherThreadUsesSameTransaction()
 {
     using (TransactionScope scope = new TransactionScope())
     {
         DatabaseConnectionWrapper connection = TransactionScopeConnections.GetConnection(db);
         ThreadTests tests  = new ThreadTests();
         Thread      thread = new Thread(tests.GetConnection);
         thread.Start(Transaction.Current);
         thread.Join();
         Assert.AreSame(connection, tests.Connection);
         Assert.AreEqual(ConnectionState.Open, tests.Connection.Connection.State);
     }
 }
Exemplo n.º 3
0
 public void Current_ShouldBeDifferentTransactionInOtherThread()
 {
     using (TransactionScope scope = new TransactionScope())
     {
         ThreadTests tests  = new ThreadTests();
         Thread      thread = new Thread(tests.GetTransactionScopeConnection);
         thread.Start();
         thread.Join();
         Assert.IsNotNull(tests.Current);
         Assert.IsNotNull(Transaction.Current);
         Assert.AreNotSame(tests.Current, Transaction.Current);
     }
 }