public void can_execute_multiple_scripts() { var task = GetTaskWithCredentials (); using (var tempdir = new TempDirectoryPathAbsolute ()) { var file1 = tempdir.SaveToTempFile (string.Format (@" create table {0} ( my_id int ); go insert into {0} values ( 1 ); go", _table)); var file2 = tempdir.SaveToTempFile(string.Format(@" insert into {0} values ( 2 )", _table)); task.ScriptFiles = new[] { file1, file2 }; task.PrepareAndAssertNoErrors (); task.ExecuteAndAssertNoErrors (); } using (var connection = GetOpenConnection ()) { using (var command = connection.CreateCommand ()) { command.CommandType = CommandType.Text; command.CommandText = "select my_id from " + _table + " where my_id = 1"; Assert.AreEqual (1, command.ExecuteScalar ()); } using (var command = connection.CreateCommand ()) { command.CommandType = CommandType.Text; command.CommandText = "select my_id from " + _table + " where my_id = 2"; Assert.AreEqual (2, command.ExecuteScalar ()); } } }
public void can_execute_script() { var task = GetTaskWithCredentials(); using (var tempdir = new TempDirectoryPathAbsolute()) { // write the script file to drive var file = tempdir.SaveToTempFile(string.Format (@" create table {0} ( my_id int ); go insert into {0} values ( 2 ); go", _table)); task.ScriptFiles = new[] { file }; task.PrepareAndAssertNoErrors(); task.ExecuteAndAssertNoErrors(); } AssertQueryReturns("select my_id from " + _table, 2); }