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); }
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); }
public static LocalSqlHelper EnableSQLConnection() { LocalSqlHelper helper = new LocalSqlHelper(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); return(helper); }