Ejemplo n.º 1
0
        public void ConfigLessFail()
        {
            DbConfig.Clear();
            var insGuid = Guid.NewGuid().ToString();

            DbAccess.ExecuteGenericCommand(string.Format("DELETE FROM {0} ", UsersMeta.TableName), null);

            DbAccess.Config.SetConfig <ConfigLessUser>(f =>
            {
                f.SetClassAttribute(new ForModelAttribute(UsersMeta.TableName));
                f.SetPrimaryKey(e => e.PropertyA);
                f.SetForModelKey(e => e.PropertyA, UsersMeta.PrimaryKeyName + "TEST");
                f.SetForModelKey(e => e.PropertyB, UsersMeta.ContentName + "TEST");
            });

            //			var unexpected = typeof(Exception);

            //#if MsSql
            //			unexpected = typeof(SqlException);
            //#endif
            //#if SqLite
            //			unexpected = typeof(SQLiteException);
            //#endif

            Assert.That(() => { DbAccess.Insert(new ConfigLessUser {
                    PropertyB = insGuid
                }); }, Throws.Exception);
        }
Ejemplo n.º 2
0
 public void ParallelAccessGlobal()
 {
     Parallel.For(0, 500, nr =>
     {
         var cache = new DbConfig(false);
         cache.EnableInstanceThreadSafety = true;
         Assert.That(cache, Is.Not.Null);
         Assert.That(cache.IsGlobal, Is.True);
         Assert.That(cache.EnableInstanceThreadSafety, Is.True);
         Assert.That(() => { cache.Include <ClassCreating>(); }, Throws.Nothing);
         Assert.That(cache.SClassInfoCaches.Count, Is.EqualTo(1));
         Assert.That(() => { Assert.That(() => cache.SClassInfoCaches.First().Value.DefaultFactory(), Is.Not.Null); },
                     Throws.Nothing);
     });
     DbConfig.Clear();
 }
Ejemplo n.º 3
0
 public static void ClearDb(DbAccessLayer mgr)
 {
     mgr.Config.Dispose();
     DbConfig.Clear();
     if (mgr.DbAccessType.HasFlag(DbAccessType.MsSql))
     {
         mgr.ExecuteGenericCommand(string.Format("DELETE FROM {0} ", UsersMeta.TableName), null);
         mgr.ExecuteGenericCommand(string.Format("DELETE FROM {0} ", ImageMeta.TableName), null);
         mgr.ExecuteGenericCommand(string.Format("DELETE FROM {0} ", BookMeta.TableName), null);
         //mgr.ExecuteGenericCommand(string.Format("TRUNCATE TABLE {0} ", ImageMeta.TableName), null);
         //mgr.ExecuteGenericCommand(string.Format("TRUNCATE TABLE {0} ", UsersMeta.TableName), null);
         //mgr.ExecuteGenericCommand(string.Format("TRUNCATE TABLE {0} ", BookMeta.TableName), null);
     }
     else if (mgr.DbAccessType.HasFlag(DbAccessType.SqLite))
     {
         mgr.ExecuteGenericCommand(string.Format("DELETE FROM {0} ", UsersMeta.TableName), null);
         mgr.ExecuteGenericCommand("VACUUM", null);
         mgr.ExecuteGenericCommand(string.Format("DELETE FROM {0} ", BookMeta.TableName), null);
         mgr.ExecuteGenericCommand("VACUUM", null);
         mgr.ExecuteGenericCommand(string.Format("DELETE FROM {0} ", ImageMeta.TableName), null);
         mgr.ExecuteGenericCommand("VACUUM", null);
     }
 }