Ejemplo n.º 1
0
 public void CheckContainsWhenUsingHardCodedValueWithPorcentageSymbol()
 {
     using (SakilaDb db = new SakilaDb())
     {
         var result = db.actors.Where(e => e.last_name.Contains("%")).ToArray();
         Assert.Equal(0, result.Count());
     }
 }
Ejemplo n.º 2
0
        public void CheckStartsWithWhenUsingValue()
        {
#if DEBUG
            Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
#endif
            using (SakilaDb db = new SakilaDb())
            {
                var result = db.actors.Where(e => e.last_name.StartsWith("Astaire")).ToArray();
                Assert.Equal(1, result.Count());
            }
        }
Ejemplo n.º 3
0
        public void CheckContainsWhenUsingVariable()
        {
#if DEBUG
            Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
#endif
            string str = "stai";

            using (SakilaDb db = new SakilaDb())
            {
                var result = db.actors.Where(e => e.last_name.Contains(str)).ToArray();
                Assert.Equal(1, result.Count());
            }
        }
Ejemplo n.º 4
0
 public void NestedTransactionsUniqueKey()
 {
     using (SakilaDb context = new SakilaDb())
     {
         var store = new store
         {
             manager_staff_id = 1
         };
         context.stores.Add(store);
         for (int i = 0; i < 10; i++)
         {
             Assert.Throws <DbUpdateException>(() => context.SaveChanges());
         }
     }
 }
Ejemplo n.º 5
0
        public void DisposeNestedTransactions()
        {
            using (SakilaDb context = new SakilaDb())
            {
                using (var trans = context.Database.BeginTransaction())
                {
                    Assert.Throws <MySqlException>(() => context.Database.ExecuteSqlCommand("update abc"));
                }
            }

            // new second transaction
            using (SakilaDb context = new SakilaDb())
            {
                using (var trans = context.Database.BeginTransaction())
                {
                    Assert.Throws <MySqlException>(() => context.Database.ExecuteSqlCommand("update abc"));
                }
            }
        }