var DbHelper = require("../core.js");
exports.testDbHelper = function (test) {
    var errorSetting2={

    }

    var baseSetting = {
        Setting: {},
        Type: ""
    }

    var mySqlSetting = {
        "Setting": {
            "host": "127.0.0.1",
            "user": "testOwner",
            "password": "123456",
            "database":"perfermance_test"
        },
        "Type": "mysql"
    }

    var baseConnection = DbHelper.GetHelper(baseSetting).BuildConnection();
    var baseConnection2=DbHelper.GetHelper(errorSetting2).BuildConnection();

    test.throws(function () {
        baseConnection.Connect()
    });

    test.throws(function(){
        baseConnection2.Connect();
    })

    var mySqlConnection=DbHelper.GetHelper(mySqlSetting).BuildConnection();
    mySqlConnection.Connect(function(error){
        if(error){
            test.failed();
            test.done();
        }
        mySqlConnection.Query("show tables",function(err,rows){
            test.ok(rows.length>0);
            test.done();
            mySqlConnection.End();
        })
    })
}
