Exemple #1
0
        public void LocalSqlHelperClosesSqlConnectionAfterDispose()
        {
            LocalSqlHelper localSqlHelper = SqlUtils.EnableSQLConnection();


            SqlConnection sqlConnection = localSqlHelper.GetOpenConnection();

            Assert.IsTrue(sqlConnection.State == ConnectionState.Open);


            localSqlHelper.Dispose();

            Assert.IsTrue(sqlConnection.State == ConnectionState.Closed);
        }
Exemple #2
0
        public void LocalSqlHelperNotClosesSqlConnectionImmediatelyAfterGetDataTable()
        {
            LocalSqlHelper localSqlHelper = SqlUtils.EnableSQLConnection();

            string query = SqlUtils.SQLQuery("Employees", selection: "Id in (3, 4, 7)", order: "Name");


            SqlConnection sqlConnection = localSqlHelper.GetOpenConnection();

            Assert.IsTrue(sqlConnection.State == ConnectionState.Open);


            DataTable dataTable = localSqlHelper.GetDataTable(query);

            Assert.IsNotNull(dataTable);

            Assert.IsFalse(sqlConnection.State == ConnectionState.Closed);
        }
Exemple #3
0
        public static LocalSqlHelper EnableSQLConnection()
        {
            LocalSqlHelper helper = new LocalSqlHelper(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);

            return(helper);
        }