public void TransactionScopeTest3()
 {
   using (var scope = new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromMinutes(10)))
   {
     using (var db = new TrackerDataContext())
     {
       db.BeginTransaction();
       var users = db.GetUsersWithRoles();
       db.CommitTransaction();
     }
     scope.Complete();
   }
 }
        public void ThreadSafeGetNamedQueryTest()
        {
            for (int tries = 0; tries < 10; tries++)
            {
                using (var db = new TrackerDataContext())
                {
                    var t1 = System.Threading.Tasks.Task.Factory.StartNew(() => db.GetUsersWithRoles());
                    var t2 = System.Threading.Tasks.Task.Factory.StartNew(() => db.GetUsersWithRoles());
                    var t3 = System.Threading.Tasks.Task.Factory.StartNew(() => db.GetUsersWithRoles());
                    var users = db.GetUsersWithRoles();

                    System.Threading.Tasks.Task.WaitAll(t1, t2, t3);

                    Assert.Greater(users.Count, 0);
                }
            }
        }
 public void TransactionScopeTest2()
 {
   using (var scope = new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromMinutes(10)))
   {
     using (var db = new TrackerDataContext())
     {
       var users = db.GetUsersWithRoles();
     }
     // no scope.Complete - rollback transaction
   }
 }
        public void StoreProcs()
        {
            using (var db = new TrackerDataContext())
            {
                var roles = db.RolesForUser(UserId);
                var users = db.GetUsersWithRoles();

                Assert.AreEqual(1, roles.Count);
                Assert.Greater(users.Count, 0);
            }
        }