Beispiel #1
0
 public UpdateTableTests()
 {
     _sb = new StringBuilder();
     _w = new ExpressionWriter(_sb,new SqlServerBuilderHelper());
     _db = Setup.GetDb();
     _builder = new UpdateTableBuilder<Post>(_db);
 }
 public AlterTableColumnTests()
 {
     _db = Setup.GetDb();
     _writer = new SqlServerDDLWriter(_db);
     _table = new ModifyTableBuilder(_db, _writer, "users");
     SetupTestTable();
 }
Beispiel #3
0
        public DbConnection Create(string cnxString)
        {
            var db = new SqlFuConnection(Provider, cnxString ?? _cnx, _config);

            db.Open();
            return(db);
        }
Beispiel #4
0
 public void sqlfu_using_another_dbconnection()
 {
     var conex = new SqlConnection(Setup.Connex);
     using (var db = new SqlFuConnection(conex, DbEngine.SqlServer))
     {
         Assert.True(db.TableExists<Post>());
     }
 }
Beispiel #5
0
 public override void Commit()
 {
     if (_db != null)
     {
         _db.Commit();
         _db = null;
     }
     else
     {
         throw new InvalidOperationException("Transaction already finished");
     }
 }
Beispiel #6
0
        public static DbConnection OpenConnection(IDbProvider provider, string connectionString)
        {
            provider.MustNotBeNull();
            if (connectionString == null)
            {
                throw new InvalidOperationException(
                          "I need a connection! Either set SqlFuFactory.Config.Providers.ConnectionString method or define a connection in config file. If there are more than one connection defined, set SqlFuFactory.Config.Providers.ConnectionString");
            }
            var sql = new SqlFuConnection(provider, connectionString);

            sql.Open();
            return(sql);
        }
Beispiel #7
0
        public static async Task <DbConnection> OpenConnectionAsync(IDbProvider provider, string connectionString, CancellationToken cancel)
        {
            provider.MustNotBeNull();
            if (connectionString == null)
            {
                throw new InvalidOperationException(
                          "I need a connection! Either set SqlFuFactory.Config.Providers.ConnectionString method or define a connection in config file. If there are more than one connection defined, set SqlFuFactory.Config.Providers.ConnectionString");
            }
            var sql = new SqlFuConnection(provider, connectionString);
            await sql.OpenAsync(cancel).ConfigureAwait(false);

            return(sql);
        }
Beispiel #8
0
        public DbConnection Create(DbConnection db = null)
        {
            SqlFuConnection cnx;

            if (db != null)
            {
                cnx = new SqlFuConnection(Provider, db, _config);
            }
            else
            {
                cnx = new SqlFuConnection(Provider, _cnx, _config);
            }
            cnx.Open();
            return(cnx);
        }
Beispiel #9
0
 public static SqlFuConnection GetDb(bool noLog = false,DbEngine engine=DbEngine.SqlServer)
 {
     var cnx = Connex;
     switch(engine)
     {
         case DbEngine.SQLite:
             DirectoryInfo dd = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
             var f = dd.Parent.Parent.FullName;
             cnx = string.Format(SqliteConnex, Path.Combine(f, "testdb.db"));                    
             //cnx = SqliteConnex;
             break;
         case DbEngine.MySql:
             cnx = MysqlConnex;
             break;
         case DbEngine.PostgreSQL:
             cnx = PostgresConnex;
             break;
     }
     var d = new SqlFuConnection(cnx, engine);
     
     return d;
 }
Beispiel #10
0
 public MyTransactionWrapper(SqlFuConnection db)
 {
     _db = db;
 }
Beispiel #11
0
 public override void Commit()
 {
     if (_db != null)
     {
         _db.Commit();
         _db = null;
     }
     else
     {
         throw new InvalidOperationException("Transaction already finished");
     }
 }
Beispiel #12
0
 public override void Rollback()
 {
     _db.Rollback();
     _db = null;
 }
Beispiel #13
0
 public SqlFuTests()
 {
     _db = new SqlFuConnection(Config.Connex, DbEngine.SqlServer);
     
 }
Beispiel #14
0
 public MyTransactionWrapper(SqlFuConnection db)
 {
     _db = db;
 }
 public CommonDatabaseToolsTests()
 {
     Db = Setup.GetDb(engine:Engine);
     SetupTable();
 }
Beispiel #16
0
 public CreateTableTests()
 {
     db = Db;
     _ddl = new SqlServerDDLWriter(db);
     db.DatabaseTools.DropTable("test");
 }
Beispiel #17
0
 public QueryTests()
 {
     _db = Config.GetDb();
 }
Beispiel #18
0
 public ComplexTypeMapper()
 {
     _db = Config.GetDb();
 }
Beispiel #19
0
 public EscapeSqlTests()
 {
     _db = Config.GetDb();
 }
Beispiel #20
0
 public override void Rollback()
 {
     _db.Rollback();
     _db = null;
 }
Beispiel #21
0
        //public static void Benchmark(Stopwatch timer,Action bench,string name,bool warm=false)
        //{
        //    var nr = warm ? WarmUp : Iterations;
        //    timer.Restart();
        //    for (int i = 0; i < nr; i++) bench();
        //    timer.Stop();
        //    if (!warm) Console.WriteLine("{0} took {1} ms",name,timer.Elapsed.TotalMilliseconds);
        //}

        public static SqlFuConnection GetDb()
        {
            var d = new SqlFuConnection(Connex, DbEngine.SqlServer);
            return d;
        }
Beispiel #22
0
 public CommonAlterTableTests()
 {
     Db = Setup.GetDb(engine: Engine);
     SetupTable();
     Table = Db.DatabaseTools.GetAlterTableBuilder(TableName);
 }
 public CommonCreateTableTests()
 {
     Db = Setup.GetDb(engine: Engine);
     SetupTable();
 }
 public QueriesWithMultiPocoMapper()
 {
     _db = Config.GetDb();
 }
Beispiel #25
0
        public HelpersTests()
        {
            _db = Config.GetDb();

              Config.EnsurePosts();
        }
 public DbExtrensionsMethodsTests()
 {
     _db = Config.GetDb();
     Config.EnsurePosts();
 }
Beispiel #27
0
 public AutomaticMigrationTests()
 {
     _db = Setup.GetDb();
 }